Several more optimizations, getting closer to a stable version in 2D