Fixed some bugs because of a new database