Heavy memory/performance optimizations #1