almost finished with server side authenticaiton storage (and minor refactoring)

not tested!