small changes to memory allocation