added basic memory management