Refactor message_queue module.

Now it contains the actual message loop. Consumers just need to call the
'message_loop' function to wait for user actions.