latest motion model code

The control structure is done, just need to get the numbers calculating
correctly. Will make fixes after I clarify a few things at our meeting
later today.