Code cleanup and optimization.