major refactoring in Ref classes: simplified template, simplified
generated code, all relations are evaluated lazy now