Refactoring, added UserUtils class. Fix some bugs.