Continue refactoring auth and add cookie cache