Added code block to flush() that creates elements on the XML DOM tree that
keep track of the id numbers.