From: Anders Eurenius <aes_AT_spotify.com>
Date: Tue, 24 Jun 2014 23:52:31 +0200
Refactor the mainloop
Try to separate the different concerns of the main loop into separate,
simpler functions. I think it's a useful step, but I also think that
more should be done.