Fixing authorization and session bugs