Fixed infinite loop, added error check for tag with missing index.