int maxRefs = refs.size();
while (refIndex < maxRefs) {
// Group references separated only by punctuation characters
int firstRefIndex = refIndex;
PageElement firstRef = refs.get(firstRefIndex);
int lastRefIndex = PageElement.groupElements(refs, firstRefIndex, contents, ",;.\'", separator);
PageElement lastRef = refs.get(lastRefIndex);
refIndex = lastRefIndex + 1;
// Remove possible whitespace characters after last reference
int tmpIndex = lastRef.getEndIndex();
boolean finished = false;
while (!finished) {
if (tmpIndex >= contents.length()) {
finished = true;
} else if (contents.charAt(tmpIndex) == '\n') {