improvements and optimizations