fix input timer queue

if new timer has a timeout later than a timer in queue, the
new timer will be discarded and never be pushed into timer queue.
This is fixed by pushing new timer without timeout checking
and then sorting the queue according to timer timeouts.

This should fix #520 and #495.