Fixes for Python 3, Python 2 compatibility not maintained.