python2 support and cleanup