Main program for structure generation