Ported to python2