Improve generator configuration.
Add Py3 compatibility.