Code-reuse for authentication
Merge pull request #30 from aw/fix_auth

Code-reuse for authentication