fix a backwards compatibility problem
clean up another batch of missed ResourceWarnings
should fix python2 compatibility problem