Implemented handling of the window resize
Added resize error handling