Added a null check to the messages save.