fixes in allocate and free