Working implementation and tests across py2/py3.