Fix NoneType error with message.references in threading algo.