remove code in global space

The current isrcsubmit has lots of code in the global (name)space.
It would be much better to have everything in functions and only have one `if __name__ == "__main__"` part.

However, we possibly need to clean-up some variable usages. We have like a dozen global variables. Creating a global `options` object a while ago was a step in the right direction.