Separated code in a main.py, added some program-level error catching to fix Serial crashes