Advanced logic for srolling. That was more complex than I thought. Fixes #3