Make input processing safe and add pause

Move the input processing into the main loop, so global mutable state
is not required.

Also move the initial pause into a full fledged pause that can be
executed at an arbitrary time.