Refactoring of authentication. This should fix #56, #92, and closes #75.

Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>