Ported library to Python 2.