More work on the rearrange function. Checking in before I strip out the dynamic position calculation.