change memory management for scripting stuff, still memory problems