Performance improvements and optimizations