Added program mode selection by file extension

Copied over from previous