Big refactoring. ORM, security, mapping