PAM, UserState changes and some optimizations