Add back code removed in r11553 and fix logic to avoid IndexError.

svn path=/main/trunk/; revision=11556
1 file changed