SQL read models, and some refactoring