Fixing bugs in scrolling code