Fixed a bug with movement

Movement would occasionally break when dir == null;