Fixing cross platform app width

 Hopefully fixes #173

This contains quite some refactoring that's not essential.
What was essential was adding the event listeners after the shell.
Hopefully that works on all platforms. Everyone please check.

It also contains some refactorings that I thought were appropriate, open for comments and suggestions as always.

Most importantly, @ashbb @wasnotrice and @davorb please try it out on Mac and Windows to make sure that it really works on all platforms.

And travis - pleeaaassseee pass.