Handle resizing
Tidy code