Started implementing memory freeing