Some much needed code cleanup