Update code based on feedback from arduino.cc/forum