fix bugs and database issues