Fixes #1 and also accounts for scrolling.