Fixed bugs with movement and added Undo functionality