Cleanup and optimize