Major controller refactor to separate crud logic from the view.