refactored, fixed some auth stuff