Refactors controllers to cut down on excessive database queries