added memory freeing.