fix lots of movement problems

this took a while because i couldn't find the real problem, so have some
syntax cleaning too