Fixed database deconnection bug