MASSIVE REFACTOR - internal auth support etc