Automated creation of needed files
Minor rearranging of code