Fixes in db.sql and added a patch.