cosmetic improvements for the csrftoken ajax fix

(cherry picked from commit 7e539e03a26c476ecb7b9a91d8e4195bf5d6d37e)