general cleanup and python3 compat