Fix straight movement end not detected correctly (#165).