Restructure gobridge.py to state machineish pattern