Cleaned up some login code, cleanups courtesy of Cowboyd