}
 
    if (do_mount || recycle) {
-      if (!mount_next_write_volume(jcr, dev, dcr->block, release)) {
+      if (!mount_next_write_volume(dcr, dcr->block, release)) {
         if (!job_canceled(jcr)) {
             /* Reduce "noise" -- don't print if job canceled */
             Jmsg(jcr, M_FATAL, 0, _("Could not ready device \"%s\" for append.\n"),
 
    /*
     * Write Begin Session Record
     */
-   if (!write_session_label(jcr, block, SOS_LABEL)) {
+   if (!write_session_label(dcr, block, SOS_LABEL)) {
       Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
         strerror_dev(dev));
       set_jcr_job_status(jcr, JS_ErrorTerminated);
     *  if we are at the end of the tape or we got a fatal I/O error.
     */
    if (ok || dev_can_write(dev)) {
-      if (!write_session_label(jcr, block, EOS_LABEL)) {
+      if (!write_session_label(dcr, block, EOS_LABEL)) {
          Jmsg1(jcr, M_FATAL, 0, _("Error writting end session label. ERR=%s\n"),
             strerror_dev(dev));
         set_jcr_job_status(jcr, JS_ErrorTerminated);
 
       }
    }
    rewind_dev(dev);
-   write_new_volume_label_to_dev(jcr, jcr->device->dev, cmd, "Default");
+   write_new_volume_label_to_dev(dcr, cmd, "Default");
    Pmsg1(-1, "Wrote Volume label for volume \"%s\".\n", cmd);
 }
 
       Pmsg0(0, _("Error writing record to block.\n")); 
       goto bail_out;
    }
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       Pmsg0(0, _("Error writing block to device.\n")); 
       goto bail_out;
    } else {
       Pmsg0(0, _("Error writing record to block.\n")); 
       goto bail_out;
    }
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       Pmsg0(0, _("Error writing block to device.\n")); 
       goto bail_out;
    } else {
       Pmsg0(0, _("Error writing record to block.\n")); 
       goto bail_out;
    }
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       Pmsg0(0, _("Error writing block to device.\n")); 
       goto bail_out;
    } else {
          Pmsg0(0, _("Error writing record to block.\n")); 
         goto bail_out;
       }
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Pmsg0(0, _("Error writing block to device.\n")); 
         goto bail_out;
       }
          Pmsg0(0, _("Error writing record to block.\n")); 
         goto bail_out;
       }
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Pmsg0(0, _("Error writing block to device.\n")); 
         goto bail_out;
       }
          Pmsg0(0, _("Error writing record to block.\n")); 
         goto bail_out;
       }
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Pmsg0(0, _("Error writing block to device.\n")); 
         goto bail_out;
       }
          Pmsg0(0, _("Error writing record to block.\n")); 
         goto bail_out;
       }
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Pmsg0(0, _("Error writing block to device.\n")); 
         goto bail_out;
       }
       Pmsg0(0, _("Error writing record to block.\n")); 
       goto bail_out;
    }
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       Pmsg0(0, _("Error writing block to device.\n")); 
       goto bail_out;
    } else {
    /*
     * Write Begin Session Record
     */
-   if (!write_session_label(jcr, block, SOS_LABEL)) {
+   if (!write_session_label(dcr, block, SOS_LABEL)) {
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
         strerror_dev(dev));
       } else if (!ok) {
         set_jcr_job_status(jcr, JS_ErrorTerminated);
       }
-      if (!write_session_label(jcr, block, EOS_LABEL)) {
+      if (!write_session_label(dcr, block, EOS_LABEL)) {
          Pmsg1(000, _("Error writting end session label. ERR=%s\n"), strerror_dev(dev));
         ok = false;
       }
       /* Write out final block of this session */
-      if (!write_block_to_device(jcr->dcr, block)) {
+      if (!write_block_to_device(dcr, block)) {
          Pmsg0(-1, _("Set ok=false after write_block_to_device.\n"));
         ok = false;
       }
    /* Copy block */
    this_file = dev->file;
    this_block_num = dev->block_num;
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       Pmsg3(000, "Last block at: %u:%u this_dev_block_num=%d\n", 
                  last_file, last_block_num, this_block_num);
       if (vol_num == 1) {
          Pmsg0(0, _("Error writing record to block.\n")); 
         goto bail_out;
       }
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Pmsg0(0, _("Error writing block to device.\n")); 
         goto bail_out;
       }
       *p = block_num;
       block->binbuf = block->buf_len;
       block->bufp = block->buf + block->binbuf;
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
         break;
       }
       if ((block_num++ % 100) == 0) {
 
        edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
        bstrftime(dt, sizeof(dt), time(NULL)));
 
-   if (!mount_next_write_volume(jcr, dev, label_blk, 1)) {
+   if (!mount_next_write_volume(dcr, label_blk, 1)) {
       free_block(label_blk);
       P(dev->mutex);
       unblock_device(dev);
 
       /* Fall through wanted! */
    case VOL_IO_ERROR:
    case VOL_NO_LABEL:
-      if (!write_new_volume_label_to_dev(jcr, dev, newname, poolname)) {
+      if (!write_new_volume_label_to_dev(jcr->dcr, newname, poolname)) {
          bnet_fsend(dir, _("3912 Failed to label Volume: ERR=%s\n"), strerror_dev(dev));
         break;
       }
 
       free_pool_memory(jcr->RestoreBootstrap);
       jcr->RestoreBootstrap = NULL;
    }
-   if (jcr->next_dev && jcr->prev_dev) {
+   if (jcr->next_dev || jcr->prev_dev) {
       Emsg0(M_FATAL, 0, _("In free_jcr(), but still attached to device!!!!\n"));
    }
    pthread_cond_destroy(&jcr->job_start_wait);
 
 #include "stored.h"                   /* pull in Storage Deamon headers */
 
 /* Forward referenced functions */
-static void create_volume_label_record(JCR *jcr, DEVICE *dev, DEV_RECORD *rec);
+static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec);
 
 extern char my_name[];
 extern int debug_level;
  *
  * Assumes that the record is already read.
  *
- * Returns: 0 on error
- *         1 on success
+ * Returns: false on error
+ *         true  on success
 */
 
-int unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
+bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec)
 {
    ser_declare;
 
              stream_to_ascii(rec->Stream, rec->FileIndex),
              rec->data_len);
       if (!forge_on) {
-        return 0;
+        return false;
       }
    }
 
    if (debug_level >= 90) {
       dump_volume_label(dev);     
    }
-   return 1;
+   return true;
 }
 
 /*
  *  Returns: false on failure
  *          true  on success
  */
-bool write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+bool write_volume_label_to_block(DCR *dcr, DEV_BLOCK *block)
 {
    DEV_RECORD rec;
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
 
    Dmsg0(20, "write Label in write_volume_label_to_block()\n");
    memset(&rec, 0, sizeof(rec));
    rec.data = get_memory(SER_LENGTH_Volume_Label);
 
-   create_volume_label_record(jcr, dev, &rec);
+   create_volume_label_record(dcr, &rec);
 
    empty_block(block);               /* Volume label always at beginning */
    block->BlockNumber = 0;
  *   Assumes that the dev->VolHdr structure is properly 
  *   initialized.
 */
-static void create_volume_label_record(JCR *jcr, DEVICE *dev, DEV_RECORD *rec)
+static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec)
 {
    ser_declare;
    struct date_time dt;
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
 
    /* Serialize the label into the device record. */
 
 
 /*
  * Create a volume label in memory
- *  Returns: 0 on error
- *          1 on success
  */
 void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName)
 {
  *
  *  This routine should be used only when labeling a blank tape.
  */
-bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, const char *PoolName)
+bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName)
 {
    DEV_RECORD rec;   
    DEV_BLOCK *block;
    bool ok = false;
+   DEVICE *dev = dcr->dev;
 
 
    Dmsg0(99, "write_volume_label()\n");
    block = new_block(dev);
    memset(&rec, 0, sizeof(rec));
    rec.data = get_memory(SER_LENGTH_Volume_Label);
-   create_volume_label_record(jcr, dev, &rec);
+   create_volume_label_record(dcr, &rec);
    rec.Stream = 0;
 
    if (!write_record_to_block(block, &rec)) {
    }
       
    Dmsg0(99, "Call write_block_to_dev()\n");
-   if (!write_block_to_dev(jcr->dcr, block)) {
+   if (!write_block_to_dev(dcr, block)) {
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
       Dmsg2(30, "Bad Label write on %s. ERR=%s\n", dev_name(dev), strerror_dev(dev));
       goto bail_out;
  * Create session label
  *  The pool memory must be released by the calling program
  */
-void create_session_label(JCR *jcr, DEV_RECORD *rec, int label)
+void create_session_label(DCR *dcr, DEV_RECORD *rec, int label)
 {
-   DCR *dcr = jcr->dcr;
+   JCR *jcr = dcr->jcr;
    ser_declare;
 
    rec->VolSessionId   = jcr->VolSessionId;
  *  Returns: false on failure
  *          true  on success 
  */
-bool write_session_label(JCR *jcr, DEV_BLOCK *block, int label)
+bool write_session_label(DCR *dcr, DEV_BLOCK *block, int label)
 {
-   DCR *dcr = jcr->dcr;
+   JCR *jcr = dcr->jcr;
    DEVICE *dev = dcr->dev;
    DEV_RECORD *rec;
 
       Jmsg1(jcr, M_ABORT, 0, _("Bad session label = %d\n"), label);
       break;
    }
-   create_session_label(jcr, rec, label);
+   create_session_label(dcr, rec, label);
    rec->FileIndex = label;
 
    /* 
    debug_level = dbl;
 }
 
-int unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec) 
+bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec) 
 {
    ser_declare;
 
         label->JobStatus = JS_Terminated; /* kludge */
       }
    }     
-   return 1;
+   return true;
 }
 
 
 
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
 
-static bool rewrite_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *bloc, bool recycle);
+static bool rewrite_volume_label(DCR *dcr, DEV_BLOCK *block, bool recycle);
 
 
 /*
  *  impossible to get the requested Volume.
  *
  */
-bool mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release)
+bool mount_next_write_volume(DCR *dcr, DEV_BLOCK *block, bool release)
 {
    int retry = 0;
    bool ask = false, recycle, autochanger;
    int vol_label_status;
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
 
    Dmsg0(100, "Enter mount_next_volume()\n");
 
                                    "Recycle") == 0))) {
          Dmsg0(100, "Create volume label\n");
         /* Create a new Volume label and write it to the device */
-        if (!write_new_volume_label_to_dev(jcr, dev, jcr->VolumeName,
+        if (!write_new_volume_label_to_dev(jcr->dcr, jcr->VolumeName,
                jcr->pool_name)) {
             Dmsg0(100, "!write_vol_label\n");
            goto mount_next_vol;
     *  If the tape is marked as Recycle, we rewrite the label.
     */
    if (dev->VolHdr.LabelType == PRE_LABEL || recycle) {
-      if (!rewrite_volume_label(jcr, dev, block, recycle)) {
+      if (!rewrite_volume_label(jcr->dcr, block, recycle)) {
         goto mount_next_vol;
       }
    } else {
  *  Returns: true if OK
  *          false if unable to write it
  */
-static bool rewrite_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool recycle)
+static bool rewrite_volume_label(DCR *dcr, DEV_BLOCK *block, bool recycle)
 {
+   DEVICE *dev = dcr->dev;
+   JCR *jcr = dcr->jcr;
+
    Dmsg1(190, "ready_for_append found freshly labeled volume. dev=%x\n", dev);
    dev->VolHdr.LabelType = VOL_LABEL; /* set Volume label */
-   if (!write_volume_label_to_block(jcr, dev, block)) {
+   if (!write_volume_label_to_block(dcr, block)) {
       return false;
    }
    /*
         }
       }
       /* Attempt write to check write permission */
-      if (!write_block_to_dev(jcr->dcr, block)) {
+      if (!write_block_to_dev(dcr, block)) {
          Jmsg2(jcr, M_ERROR, 0, _("Unable to write device \"%s\". ERR=%s\n"),
            dev_name(dev), strerror_dev(dev));
         return false;
 
 
 /* From label.c */
 int      read_dev_volume_label(DCR *dcr, DEV_BLOCK *block);
-void     create_session_label(JCR *jcr, DEV_RECORD *rec, int label);
+void     create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
 void     create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
-bool     write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, const char *PoolName);
-bool     write_session_label(JCR *jcr, DEV_BLOCK *block, int label);
-bool     write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+bool     write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName);
+bool     write_session_label(DCR *dcr, DEV_BLOCK *block, int label);
+bool     write_volume_label_to_block(DCR *dcr, DEV_BLOCK *block);
 void     dump_volume_label(DEVICE *dev);
 void     dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
-int      unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
-int      unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
+bool     unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
+bool     unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
 
 /* From match_bsr.c */
 int      match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, 
 bool     match_set_eof(BSR *bsr, DEV_RECORD *rec);
 
 /* From mount.c */
-bool     mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool release);
+bool     mount_next_write_volume(DCR *dcr, DEV_BLOCK *block, bool release);
 bool     mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
 void     release_volume(JCR *jcr, DEVICE *dev);
 void     mark_volume_in_error(JCR *jcr, DEVICE *dev);