Fix problems in timed write to serial