pulled from ir branch, fixed for teensy3.X