Updates that allow registry script to update the lastid field more efficiently
by calling the metacat 'getlastdocid' function for a given scope. Also some
debugging support added, and a bug where the error message was inproperly
saved across calls to metacat, resulting in spurious error messages.