Refactor event handlers & handle window resizing