Added lazy resizing instead of triggering the whole function on every resize event.