Converted to Python3, added a few features. Passes tests.
Tweaked around for compatibility between Py3/2. Tests pass for both.