Apply outstanding patch to address various problems in auth code.

1839028 Potential problems in auth code
1839023 OS freeze: race condition in the auth code.
1839009 Auth rules with both "quick" and "keep state" don't work
7 files changed