Many parts of the model can be useful in controller.xql and are actually already evaluated there.
It might be useful, to create the model in the controller (where appropriate or always, that remains to be evaluated) and hand it down to the functions by a parameter.
This will help