More thread safety for DB & don't save incorrect image