Changed index conversion to use ostringstream.