Move scroll margin to its own action and fix bugs with it.