move alloc stuff into a separate file