diff --git a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
index 6adfdb8394d573cc602c1803ac87acb80a64a286..fa42a7ac209591b2a4f1adceab87f92e58c35ddc 100644
--- a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
+++ b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
@@ -71,14 +71,17 @@
    "outputs": [],
    "source": [
     "# imports, usually no need to change anything here\n",
-    "import os\n",
+    "from datetime import datetime\n",
+    "import dateutil.parser\n",
     "import h5py\n",
+    "import os\n",
+    "\n",
+    "\n",
     "import numpy as np\n",
     "import matplotlib\n",
     "matplotlib.use(\"Qt4Agg\")\n",
     "import matplotlib.pyplot as plt\n",
     "%matplotlib inline\n",
-    "\n",
     "# make sure a cluster is running with ipcluster start --n=32, give it a while to start\n",
     "from ipyparallel import Client\n",
     "\n",
@@ -91,13 +94,13 @@
     "warnings.filterwarnings('ignore')\n",
     "\n",
     "from iCalibrationDB import ConstantMetaData, Constants, Conditions, Detectors, Versions\n",
-    "\n",
     "from cal_tools.tools import gain_map_files, parse_runs, run_prop_seq_from_path, get_notebook_name, get_dir_creation_date\n",
     "from cal_tools.influx import InfluxLogger\n",
     "from cal_tools.enums import BadPixels\n",
     "from cal_tools.plotting import show_overview, plot_badpix_3d\n",
     "from cal_tools.agipdlib import get_acq_rate, get_num_cells, get_gain_setting\n",
-    "from datetime import datetime\n",
+    "\n",
+    "\n",
     "\n",
     "IL_MODE = interlaced \n",
     "maxcells = mem_cells if not interlaced else mem_cells*2\n",
@@ -127,30 +130,6 @@
     "print(\"Detector in use is {}\".format(loc))"
    ]
   },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "control_fname = f'{in_folder}/r{runs[0]:04d}/RAW-R{runs[0]:04d}-{karabo_da_control}-S00000.h5'\n",
-    "\n",
-    "if gain_setting == 0.1:\n",
-    "    if creation_time.replace(tzinfo=None) < dateutil.parser.parse('2020-01-31'):\n",
-    "        print(\"Set gain-setting to None for runs taken before 2020-01-31\")\n",
-    "        gain_setting = None\n",
-    "    else:\n",
-    "        try:\n",
-    "            gain_setting = get_gain_setting(control_fname, h5path_ctrl)\n",
-    "        except Exception as e:\n",
-    "            print(f'Error while reading gain setting from: \\n{control_fname}')\n",
-    "            print(e)\n",
-    "            print(\"Gain setting is not found in the control information\")\n",
-    "            print(\"Data will not be processed\")\n",
-    "            sequences = []\n",
-    "print(f\"Gain setting: {gain_setting}\")"
-   ]
-  },
   {
    "cell_type": "markdown",
    "metadata": {},
@@ -184,10 +163,10 @@
     "        acq_rate = get_acq_rate(fname, loc, channel)\n",
     "        print(\"Acquisition rate set from file: {} MHz\".format(acq_rate))\n",
     "    \n",
-    "    # Run's creation time:\n",
+    "    # Define constant creation time.\n",
     "    if creation_time:\n",
     "        try:\n",
-    "            creation_time = datetime.datetime.strptime(creation_time, '%Y-%m-%d %H:%M:%S.%f')\n",
+    "            creation_time = datetime.strptime(creation_time, '%Y-%m-%d %H:%M:%S.%f')\n",
     "        except Exception as e:\n",
     "            print(f\"creation_time value error: {e}.\" \n",
     "                   \"Use same format as YYYY-MM-DD HR:MN:SC.ms e.g. 2019-07-04 11:02:41.00/n\")\n",
@@ -219,6 +198,30 @@
     "    print(\"Using {} as creation time\".format(creation_time.isoformat()))"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "control_fname = f'{in_folder}/r{runs[0]:04d}/RAW-R{runs[0]:04d}-{karabo_da_control}-S00000.h5'\n",
+    "\n",
+    "if gain_setting == 0.1:\n",
+    "    if creation_time.replace(tzinfo=None) < dateutil.parser.parse('2020-01-31'):\n",
+    "        print(\"Set gain-setting to None for runs taken before 2020-01-31\")\n",
+    "        gain_setting = None\n",
+    "    else:\n",
+    "        try:\n",
+    "            gain_setting = get_gain_setting(control_fname, h5path_ctrl)\n",
+    "        except Exception as e:\n",
+    "            print(f'Error while reading gain setting from: \\n{control_fname}')\n",
+    "            print(e)\n",
+    "            print(\"Gain setting is not found in the control information\")\n",
+    "            print(\"Data will not be processed\")\n",
+    "            sequences = []\n",
+    "print(f\"Gain setting: {gain_setting}\")"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,