Work on motion

It is almost working. I just need to work out some of the bugs.