Fix flip-flip factories to work in Python 2