Script Generation

Working, needs sanity checking, a few other things.