diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index cd70da6601727d7d1fc7a5b99b78283f93778211..0877b8ddea4747eb88a1fff3ba3affc3f7639d11 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -125,8 +125,8 @@ class AgipdCorrections:
         # avoid list(range(*[0]]))
         self.pulses_lst = list(range(*max_pulses)) \
             if not (len(max_pulses) == 1 and max_pulses[0] == 0) else max_pulses  #noqa
-        self.min_pulse = int(self.pulses_lst[0])
-        self.max_pulse = int(self.pulses_lst[-1])
+        self.min_pulse = self.pulses_lst[0]
+        self.max_pulse = self.pulses_lst[-1]
         self.max_cells = max_cells
         self.hist_pulses = 0
         self.hists_signal_low = 0
@@ -1047,10 +1047,11 @@ class AgipdCorrections:
             copim[copim < self.median_noise] = np.nan
 
             # avoid 0 hist_pulses, otherwise histogram plot will fail
+            # hist_pulse must be of a type(int)
             if self.max_pulse == 0:
-                self.hist_pulses = self.max_pulse + 1
+                self.hist_pulses = int(self.max_pulse + 1)
             else:
-                self.hist_pulses = self.max_pulse
+                self.hist_pulses = int(self.max_pulse)
 
             bins = (self.bins_signal_low_range, self.hist_pulses)
             rnge = [[-50, 1000], [self.min_pulse,
diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index 42e5f5b02fc9c41cc632f31ccfcdd35f323c4b0f..2286d4640a732f2526ff9a6ea1b67cf8140a4fee 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -376,7 +376,7 @@
      "end_time": "2019-02-21T11:30:16.057429Z",
      "start_time": "2019-02-21T11:30:10.082114Z"
     },
-    "scrolled": false
+    "scrolled": true
    },
    "outputs": [],
    "source": [
@@ -609,7 +609,8 @@
     "                all_cells.append(cells)\n",
     "                whens.append((qm, when))\n",
     "                errors.append(err)\n",
-    "                if not init_hist:\n",
+    "                # Validate hp to be int not None.\n",
+    "                if not init_hist and hp is not None:\n",
     "                    hists_signal_low =  np.zeros((bins_signal_low_range, hp), np.float64)\n",
     "                    hists_signal_high =  np.zeros((bins_signal_low_range, hp), np.float64)\n",
     "                    init_hist = True\n",
@@ -716,7 +717,8 @@
    },
    "outputs": [],
    "source": [
-    "do_3d_plot(hists_gain_vs_signal, signal_edges, \"Signal (ADU)\", \"Analogue gain (ADU)\")"
+    "if signal_edges is not None:\n",
+    "    do_3d_plot(hists_gain_vs_signal, signal_edges, \"Signal (ADU)\", \"Analogue gain (ADU)\")"
    ]
   },
   {
@@ -741,8 +743,8 @@
     "    cb = fig.colorbar(im)\n",
     "    cb.set_label(\"Counts\")\n",
     "    \n",
-    "    \n",
-    "do_2d_plot(hists_gain_vs_signal, signal_edges, \"Signal (ADU)\", \"Gain Value (ADU)\")"
+    "if signal_edges is not None:\n",
+    "    do_2d_plot(hists_gain_vs_signal, signal_edges, \"Signal (ADU)\", \"Gain Value (ADU)\")"
    ]
   },
   {
@@ -765,7 +767,8 @@
    },
    "outputs": [],
    "source": [
-    "do_2d_plot(hists_dig_gain_vs_signal, dig_signal_edges, \"Signal (ADU)\", \"Gain Bit Value\")"
+    "if dig_signal_edges is not None:\n",
+    "    do_2d_plot(hists_dig_gain_vs_signal, dig_signal_edges, \"Signal (ADU)\", \"Gain Bit Value\")"
    ]
   },
   {
@@ -780,9 +783,10 @@
    "outputs": [],
    "source": [
     "fig, ax = plt.subplots()\n",
-    "ax.pie(gain_stats, labels=[\"high\", \"medium\", \"low\"], autopct='%1.2f%%',\n",
-    "        shadow=True, startangle=27)\n",
-    "a = ax.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle."
+    "if gain_stats != 0:\n",
+    "    ax.pie(gain_stats, labels=[\"high\", \"medium\", \"low\"], autopct='%1.2f%%',\n",
+    "            shadow=True, startangle=27)\n",
+    "    a = ax.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle."
    ]
   },
   {
@@ -806,10 +810,12 @@
    },
    "outputs": [],
    "source": [
-    "do_3d_plot(hists_signal_low, low_edges, \"Signal (ADU)\", \"Pulse id\")\n",
-    "do_2d_plot(hists_signal_low, low_edges, \"Signal (ADU)\", \"Pulse id\")\n",
-    "do_3d_plot(hists_signal_high, high_edges, \"Signal (ADU)\", \"Pulse id\")\n",
-    "do_2d_plot(hists_signal_high, high_edges, \"Signal (ADU)\", \"Pulse id\")"
+    "if low_edges is not None:\n",
+    "    do_3d_plot(hists_signal_low, low_edges, \"Signal (ADU)\", \"Pulse id\")\n",
+    "    do_2d_plot(hists_signal_low, low_edges, \"Signal (ADU)\", \"Pulse id\")\n",
+    "if high_edges is not None:\n",
+    "    do_3d_plot(hists_signal_high, high_edges, \"Signal (ADU)\", \"Pulse id\")\n",
+    "    do_2d_plot(hists_signal_high, high_edges, \"Signal (ADU)\", \"Pulse id\")"
    ]
   },
   {