Still missing some things, this is part 1.
* Always create main window. * Properly handle netowrk manager - it was created twice, leading to potential crashes.