Refactored code for cleanliness and repetition.
Added functionality for authentication.
Added functionality for signing in and registering.
Refactored code for edge cases.