Fixed the authentication, but there are some bugs still.
Merged a conflict.