Added main func codegen. Not tested yet!!