Some of today's work, before further cleanup. Mostly memory optimizations