Code optimization and cleanup.