Quad tree related performance and memory consumption optimizations