Made a few tweaks to allow for Py3K compatibility.