refactoring for better structure and better lazy loading support

(relations are not working again)