This is a raw outline of the movement code

None of this is final and a lot of it is experimental and uncommented.