Made code hopefully Python3-compatible.