Fixed bugs caused by database changes