performance improvements for python2.7