Clean up and performance improvements.