added automatic main method generation, explicit use of use_region_array switch