misc. Python portability fixes