Added tracking of previous robot's index.