merge some changes from basic-auth branch