Controls code cleanup and refactoring