Fixes scroll and resize event bugs