Controller code cleanup

-Removed unused variables
-Added comments
-Removed pointless tabs and new lines
-Renamed functions to maintain consistency
-fixed tabbing