First version of the generator, still some bugs to remove