Speed it up, and cleaned up the gen, and added the -n option