Added in some previous memory-management, along with skeloton of function for memory management.