Pretty much a total rewrite of the controller