Unify exec python

Combines the two implementations of "execute_python_code_in_main_module". And some follow-on cleanup.