extensive updates to the db library, adding fields to the query builder