Command code cleanup and optimization.