Updates to database analysis code

(This code is not used by any of the command line scripts
at the moment.)