Copy fix from Java Mode to allow serial library to work