Semi-working version.

Still needs to behave properly when the speed is increased.