Cleanup and preparation for py3