Fixed a few bugs. Added generation batching.