Cleaned up the authentication codes, it's more readable now