Clean-up and optimization