Fix deallocation of memory blocks

Deallocate memory blocks correctly with original block size (to make non-standard allocators work).