Create a registry for data repository factories

Also refactor the way repositories are created using the Model API
Rewrite to fix tests
Merge remote-tracking branch 'origin/master'