Move message saving out of helpers.js