Refactors expression building code out of Controller.