Finished rewrite memory allocator
Didn't test it thoroughly yet, so there might still be a few glitches left.