Fixed errors after the changes to database