Improve memory management. Change unnecessary GC allocations to custom allocations. Add shared_ptr to improve memory management. Switch derelict maintenance. Tidy up code.