UsersController cleanup

Pulled out some helper functions and fixed a few cases of logic duplication.