Changes to fix some minor issues in database handling as well in client code