Fix some bugs regarding database and download file.