Fix some bugs in save/load database.