Refactored out controllers and cleaned up code