Clean-up and optimizations.