Implemented a bit of memory freeing