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