Heavy memory/performance optimizations #4