Fix of issue #459

While fixing the bug, I added some extra options, and docstrings.

I don't see any reason for keeping generate2.py, so I removed it.