Made changes to allow auto-generation of main.