Integrated Peter's _handle_movement fixes.