Login Refactor

Refactored most of the login code. The login system is now following a
object oriented design.