fix bugs introduced due to the new database interface.