cleanup and some python3 corrections