a little restructuring for more reasonable memory management during the db fill process