Fixed minor possible undefined behaviour.
Fixed bad queuing of input management. Fixes #42; introduced in 40216ce6dec0ee3725b4ee83850ac55bd6a819ba.