Clean up and optimizations