Bugfix and rewrite of CFG generation

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