Fixed python 3 compatibility more fully