Added a completion handler and did some refactoring, and now it works!
Sign in/out and some refactoring.