Rewrite data generation portion

This is entirely untested...