Finished most of the generation code. Still need to add some features and
test it though.