Clean up and optimize