Make middleware changes work on python 3.3.3