Refactoring child processes so that they clean up properly and restart on error if the serial port is still connected.