Added signal to redraw window while resizing.
And moved some code to functions
Removed 2 lines