Fix bugs and update db.sql