Refactor movement functions.