Feature #4149 : modifying models and query mechanism around users
- removing some dead code
- centralizing/refactoring some code