Cleanup app and mainwindow

That code is needed only in the mainwindow and gets passed as a parameter where is no need of that.
The idea is to cleanup app.py to ease the separation of logic.
There is a little of twisted being used right now in the mainwindow so right now we need this.
I'll remove/update this when all the twisted code is removed from the mainwindow.