Clean up message edit code