Fix query and update progress bar.

Also, reduce number of items to take at a time, to reduce the chance of PHP execution timeout issues...  Don't know why it hasn't already happened, but anyway...