Added special motions and cleaned up the code