Fix bug and add minor speed improvement for xls download