Replaced gen with gen2

As part of an effort to minimize reliance on external packages, I've
written functions for gen which are as fast (sometimes even a bit
faster) than the imported itertools versions we were using. We no longer
need to import itertools.py.