Prevent fatal error if the db is invalid

Close #7