Refactoring thumbnail scroll code to fix jumps