Account for encoder rollover correctly