various cleanups to work with python2