Bug fixes
Fixed some bugs that appear when the database is empty.