Refactored main search utility.

The main changes are:
 * The results is accumulated into a StringIO object.
 * Prevented concurrent write-access to GetRecords.xml. Now all
   modifications on GetRecords.xml are taking place on a local copy.
 * Removed unneeded calls to clear().