Massive refactor in auth and Resource

... to handle all auth related stuff where it belongs.