Cleanup and moved main to controller