Clean and optimize