Fixes bugs with the panning logic.