diff --git a/ScanOperator.sh b/ScanOperator.sh
index 4bda183bda29d841d191b9e24d77ea983f61354b..e1ad44215dc762915561b6cb90eead6b3a1bb194 100755
--- a/ScanOperator.sh
+++ b/ScanOperator.sh
@@ -81,7 +81,7 @@ done
 echo "--------------------------------"
 
 if [ -z $CFGFILE ];then
-    echo "[ error ][so] You didn't specify the json cfg file."
+    echo "[ error ][so] You didn't specify the json cfg file (option \"-j\")."
     echo "[ error ][so] The default one is under configs/config.json"
     usage
     exit
@@ -110,7 +110,7 @@ mkdir -p $SOBASE/data/$SO_RUNNUMBER
 
 if [ ! -d "$YARRBASE" ]; then
     echo -e "[ error ][so] Please specify a valid path to Yarr under \n" \
-            "             \".YARR.YARR_directory\" in the main config file"
+            "             \".YARR.YARR_directory\" in the \"-j\" config file"
     exit 1
 fi
 
@@ -166,7 +166,7 @@ fi
 
 
 if [ -z $module_id ];then
-    echo "You didn't specify the Module ID (option '-m')."
+    echo "Please specify a Module ID (option '-m'). "
     usage
 fi
 
@@ -176,8 +176,10 @@ if [ "$value" = "null" ]; then
     exit
 fi
 
+nChips="$(jq -j --arg b ${module_id} '.modules."\($b)".chips | length' $CFGFILE)"
+cfgdir=$SOBASE/configs/rd53a/$module_id
+
 if $createConfig ; then
-    cfgdir=$SOBASE/configs/rd53a/$module_id
     rm -rf $cfgdir
     echo "[ info ][so] Creating configs for module \"$module_id\""
 
@@ -186,6 +188,7 @@ if $createConfig ; then
     retval=$?
     if [ $retval -ne 0 ]; then
         if [ "$qcOpt" = "-Q" ]; then
+            echo "[ info ][so] Please use localdb's viewer to register the module from iTkPD"
             exit
         else
             rm -rf $cfgdir
@@ -197,33 +200,65 @@ if $createConfig ; then
             done
             if [[ ${answer} == "y" ]]; then
 
-                regCompFile="$SOBASE/configs/moduleRegistrationCfgFiles/register_component_rd53a.json"
                 userFile="$SOBASE/configs/moduleRegistrationCfgFiles/user.json"
                 siteFile="$SOBASE/configs/moduleRegistrationCfgFiles/site.json"
 
                 echo "------------------------"
 
-                echo "Module information file (\"$regCompFile\")"
-                cat $regCompFile | jq .
-
-                echo -e "\nSite information (\"$siteFile\")"
+                echo -e "\n[ info ][so] Site information (\"$siteFile\")"
                 cat $siteFile | jq .
 
-                echo -e "\nUser information (\"$userFile\")"
+                echo -e "\n[ info ][so] User information (\"$userFile\")"
                 cat $userFile | jq .
 
-                echo -e "\nPlease make sure that these files (and \"register_component_rd53a.json\" in particular) are correct and consistent with your config.json file before proceeding. Edit them manually if that's not the case (to be improved in future versions)"
+                echo ""
+
+                # Generate module information file
+                # > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 
+                modRegFile=$SOBASE/configs/moduleRegistrationCfgFiles/modRegFile.json
+                touch $modRegFile
+
+                echo "{}" > $modRegFile
+
+                chipType=$(jq -j --arg a $module_id '.modules."\($a)".chipType' $CFGFILE)
+
+                jq --arg a $module_id '."module" = {"serialNumber": "\($a)", "componentType": "Module"}' $modRegFile > tmp && mv tmp $modRegFile
+                jq --arg a $chipType '."chipType" = "\($a)"' $modRegFile > tmp && mv tmp $modRegFile
+                jq '."chips" = []' $modRegFile > tmp && mv tmp $modRegFile
+
+                for (( i=0; i<$nChips; i++ ))
+                do
+                    chipId="$(jq -j --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].Parameter.ChipId' $CFGFILE)"
+                    chipName="$(jq -j --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].connectivity.name' $CFGFILE)"
+
+                    jq --argjson a ${i} --arg v $chipName '.chips[$a].serialNumber = "\($v)"' $modRegFile > tmp && mv tmp $modRegFile
+                    jq --argjson a ${i}  '.chips[$a].componentType = "Front-end Chip"' $modRegFile > tmp && mv tmp $modRegFile
+                    jq --argjson a ${i} --argjson b ${chipId}  '.chips[$a].chipId = $b' $modRegFile > tmp && mv tmp $modRegFile
+                done
+
+                echo "[ info ][so] Module registration file, (autogenerated from \"$CFGFILE\")"
+                cat $modRegFile | jq .
+                # < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < 
+
+
+                echo -e "\n[ info ][so] Please make sure that these files (and the module registration file in particular) are correct and consistent with your config.json file before proceeding."
                 echo "------------------------"
                 
                 echo "Are you ok with the settings above?"
-
                 unset answer
                 while [ -z "${answer}" ]; do
                     read -p "[y/n]: " answer
                 done
                 if [[ ${answer} == "y" ]]; then
-                    $YARRBASE/bin/dbAccessor -C -c $regCompFile -u $userFile -i $siteFile
+                    retval=$($YARRBASE/bin/dbAccessor -C -c $modRegFile -u $userFile -i $siteFile)
+                else
+                    echo "[ info ][so] ok! Make the appropiate changes and come again"
+                    exit
                 fi
+
+                #Retrieve cfg files from localdb
+                cmd="$YARRBASE/bin/dbAccessor -D -n $module_id -p $cfgdir"
+                $cmd
             else
                 echo "Do you continue scan with temporary config files?"
 
@@ -241,7 +276,6 @@ if $createConfig ; then
                 if [ "$chiptype" != "null" ]; then
                     conn=$(echo $conn | jq ".chipType |= .+\"$chiptype\"")
                 fi
-                nChips="$(jq -j --arg a $module_id '.modules."\($a)".chips | length' $CFGFILE)"
                 cnt=0
                 while [ $cnt -lt $nChips ]; do
 
@@ -273,7 +307,6 @@ if $createConfig ; then
         fi
     fi
 
-    nChips="$(jq -j --arg b ${module_id} '.modules."\($b)".chips | length' $CFGFILE)"
 
 
     
@@ -417,6 +450,13 @@ if $dcsOnOff ;then
     done
 fi
 
+if [[ ! -d "$cfgdir" ]]
+then
+    echo "[ error ][so] Not found config files for module \"$module_id\". Please run the S.O. again with the '-c' option to create them"
+    exit
+fi
+
+
 echo -e "\n[ info ][so] Running the sequence of scans"
 
 
diff --git a/configs/config.json b/configs/config.json
index 33b19e489bc9dcfa06a4ae60cf5a00fe01acd4cb..91cedd8a7d7cca4ba2b8a4e0ec6540d27c4cd043 100644
--- a/configs/config.json
+++ b/configs/config.json
@@ -9,12 +9,7 @@
         "scan_list":
         [
             ["std_digitalscan"],
-            ["std_analogscan"],
-            ["diff_tune_globalthreshold", 1000],
-            ["diff_tune_pixelthreshold", 1000],
-            ["diff_tune_globalpreamp", 7],
-            ["diff_tune_pixelthreshold", 1000],
-            ["diff_thresholdscan"]
+            ["diff_tune_globalthreshold", 1000]
         ]
         
     },
@@ -39,7 +34,8 @@
                     },
                     "Parameter":
                     {
-                        "ChipId": 0
+                        "ChipId": 0,
+                        "Name": "SNCHIP1"
                     }
                 }
             ]
@@ -72,7 +68,7 @@
                     },
                     "Parameter":
                     {
-                        "Name": "JohnDoe_chip1",
+                        "Name": "SNCHIP1",
                         "ChipId": 1
                     }
                 },
@@ -99,7 +95,7 @@
                     },
                     "Parameter":
                     {
-                        "Name": "JohnDoe_chip2",
+                        "Name": "SNCHIP2",
                         "ChipId": 2
                     }
                 },
@@ -126,7 +122,7 @@
                     },
                     "Parameter":
                     {
-                        "Name": "JohnDoe_chip3",
+                        "Name": "SNCHIP3",
                         "ChipId": 3
                     }
                 },
@@ -153,7 +149,7 @@
                     },
                     "Parameter":
                     {
-                        "Name": "JohnDoe_chip4",
+                        "Name": "SNCHIP4",
                         "ChipId": 4
                     }
                 }
diff --git a/configs/influxdb_connectivity.json b/configs/influxdb_connectivity.json
index 24d3f749787011fc8281cf3e42cf913030db17d9..9cf0ccd2f4432bc44a02af37b65ebf3c37c652b4 100644
--- a/configs/influxdb_connectivity.json
+++ b/configs/influxdb_connectivity.json
@@ -1,12 +1,7 @@
 {
-    "influxdb_cfg":
-    {
-        "username": "uName",
-        "database": "dbName",
-        "measurement": "measName",
-        "host": "127.0.0.22",
-        "port": 8086
-    },
+    "hostIp": "127.0.0.1",
+    "hostPort": "27017",
+    "dbName": "localdb",
     "environment": [
         "vddd_voltage",
         "vddd_current",
@@ -16,8 +11,21 @@
         "vddcom_current",
         "hv_voltage",
         "hv_current",
-        "temperature"
+        "temperature",
+        "hv_mode"
     ],
+
+
+    "influxdb_cfg":
+    {
+        "username": "uName",
+        "database": "dbName",
+        "measurement": "measName",
+        "host": "127.0.0.22",
+        "port": 8086
+    },
+
+    
     "environments": [
         {
             "measurement": "measName",
diff --git a/configs/moduleRegistrationCfgFiles/user.json b/configs/moduleRegistrationCfgFiles/user.json
index 2e1d5ab64dfad35c6078ce727fb06991c70c7b92..073cb7b19f8e4bc9c4861c8eb52fa962ee215890 100644
--- a/configs/moduleRegistrationCfgFiles/user.json
+++ b/configs/moduleRegistrationCfgFiles/user.json
@@ -1,5 +1,5 @@
 {
-    "userName": "Mario",
-    "institution": "Osaka University",
+    "userName": "Taro",
+    "institution": "Osk U",
     "description": "default"
 }
diff --git a/libDCS/ivscan.py b/libDCS/ivscan.py
index a4aa5e3964008aa3f3e66b2ea6c963a2f90fb611..1ee301d67e3de7acd9b91ac2aca6f171d9cb3913 100644
--- a/libDCS/ivscan.py
+++ b/libDCS/ivscan.py
@@ -13,12 +13,10 @@ from influxdb import InfluxDBClient
 try:
     import labRemote
 except:
-    print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
+    print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by doing")
     print()
     print("     export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
     print()
-    print("     or writing \"/path/to/labRemote/build/lib\" in config.json (\"dcs_control\" section)")
-    print()
     print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
     exit(1)
 
@@ -44,20 +42,22 @@ def setUpPassiveChannels(config, curve, what):
     
     if what == "turnOn":
         for elem in config[curve]["passive_channels"]:
+            if elem != {}:
 
-            ps = hw.getPowerSupplyChannel(elem["name"])
+                ps = hw.getPowerSupplyChannel(elem["name"])
 
-            print()
-            print("setting I to %2g A and V to %2g V on channel %s" % (elem["current"], elem["voltage"], elem["name"]))
-            ps.setVoltageLevel(elem["voltage"])
-            ps.setCurrentLevel(elem["current"])
+                print()
+                print("setting I to %2g A and V to %2g V on channel %s" % (elem["current"], elem["voltage"], elem["name"]))
+                ps.setVoltageLevel(elem["voltage"])
+                ps.setCurrentLevel(elem["current"])
 
-            ps.turnOn()
+                ps.turnOn()
 
     elif what == "turnOff":
         for elem in config[curve]["passive_channels"]:
-            ps = hw.getPowerSupplyChannel(elem["name"])
-            ps.turnOn()
+            if elem != {}:
+                ps = hw.getPowerSupplyChannel(elem["name"])
+                ps.turnOn()
 
 
 
@@ -71,6 +71,24 @@ def doSensorIV(config):
     ps.setCurrentLevel(ch["setting_current"])
     ps.setCurrentProtect(ch["current_protection"])
 
+
+
+    data = {}
+
+    data['unit'] = {}
+    data['unit']['Time'] = 's'
+    data['unit']['Voltage'] = 'V'
+    data['unit']['Current'] = 'A'
+
+    data["V_step"] = config["sensor_iv"]["target_channel"]["step_size"]
+    data["Step_duration"] = config["sensor_iv"]["target_channel"]["sleeping_time_s"]
+    data["N_measurements_per_step"] = config["sensor_iv"]["target_channel"]["measurements_per_step"]
+    data["I_Compliance"] = config["sensor_iv"]["target_channel"]["current_protection"]
+
+    data['Sensor_IV'] = []
+
+
+
     print("\ntime\t"+"voltageLevel\t"+"voltageValue\t"+"voltageStd\t"+"currentValue\t"+"currentStd")
 
     start = time.time()
@@ -101,6 +119,11 @@ def doSensorIV(config):
         iMean = np.mean(iListPerStep)
         iStd  = np.std(iListPerStep)
 
+        data['Sensor_IV'].append({"Time" : elapsedTime})
+        data['Sensor_IV'][-1]["Voltage"] = vMean
+        data['Sensor_IV'][-1]["Current_mean"] = iMean
+        data['Sensor_IV'][-1]["Current_sigma"] = iStd
+
         vi.append([vMean, iMean])
         print("%.2g\t%.2g\t \t%.2g\t \t%.2g\t \t%.2g\t \t%.2g" % (elapsedTime, v, vMean, vStd, iMean, iStd))
 
@@ -110,10 +133,12 @@ def doSensorIV(config):
         ps.turnOff()
         setUpPassiveChannels(config, "sensor_iv", "turnOff")
 
-        if len(vi) > 1 and (abs(vi[-1][1] - vi[-2][1]) <= 0.01 and abs(vi[-1][1] - ch["current_protection"]) <= 0.01):
+        if vi[-1][1] > ch["current_protection"]:
+            print("Reached current protection value")
             break
 
-
+    with open("data.json", "w") as f:
+        json.dump(data, f, indent=4)
 
 def doModuleVI(config):
 
@@ -136,7 +161,7 @@ def doModuleVI(config):
 
         # turn everything on
         ps.turnOn()
-        setUpPassiveChannels(config, "sensor_iv", "turnOn")
+        setUpPassiveChannels(config, "module_vi", "turnOn")
 
         ps.setCurrentLevel(i)
 
@@ -157,7 +182,7 @@ def doModuleVI(config):
 
         # turn everything off
         ps.turnOff()
-        setUpPassiveChannels(config, "sensor_iv", "turnOff")
+        setUpPassiveChannels(config, "module_vi", "turnOff")
 
         print("%.2g\t%.2g\t \t%.2g\t \t%.2g\t \t%.2g\t \t%.2g" % (elapsedTime, i, vMean, vStd, iMean, iStd))
         i += ch["step_size"]
@@ -168,10 +193,10 @@ def ivscan(hw, args):
     with open(args.json) as f:
         config = json.load(f)
 
-    if args.what == "iv" or args.what == "both":
+    if args.what == "iv":
         doSensorIV(config)
 
-    if args.what == "vi" or args.what == "both":
+    if args.what == "vi":
         doModuleVI(config)
 
 
@@ -201,7 +226,7 @@ if __name__ == "__main__":
         "-w",
         "--what",
         required=True,
-        help="'iv' for IV curve, 'vi' for vi curve. 'both' for both)",
+        help="'iv' for IV curve, 'vi' for vi curve.)",
     )
     parser.add_argument(
         "-j",
diff --git a/libDCS/qaqc.py b/libDCS/qaqc.py
index 54052feb201d16e3e546f824aa948c54a9bc4197..c94bddccd7882e068e96032f1bbdd5abc6fd6be5 100644
--- a/libDCS/qaqc.py
+++ b/libDCS/qaqc.py
@@ -9,7 +9,7 @@ from influxdb import InfluxDBClient, exceptions
 
 
 try:
-    import labRemote
+    import _labRemote as labRemote
 except:
     print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
     print()
@@ -75,7 +75,6 @@ def measure(hw, ps, args):
     chList = args.channel.split(',')
 
     points = [] # a whole row, sharing the same timestamp.
-    now = int(time.time()*1e3)
 
     with open(args.dbConnectivity) as f:
         psConfig = json.load(f)
@@ -86,7 +85,6 @@ def measure(hw, ps, args):
         ps = hw.getPowerSupplyChannel(ch)
         point = {
             "measurement": dbSink["measurement"],
-            "time": now,
             "fields": {
                 "measV_"+ch: ps.measureVoltage(),
                 "measI_"+ch: ps.measureCurrent(),
@@ -167,7 +165,7 @@ def toInfluxDB(points, dbSink, host='localhost', port=8086):
         sys.exit(1)
 
     try:
-        client.write_points(points, time_precision = 'u')
+        client.write_points(points, time_precision = 'n')
     except exceptions.InfluxDBClientError as e:
         print("[ error ] Received error from InfluxDB: {}".format(e))
         sys.exit(1)
diff --git a/scanLauncher.sh b/scanLauncher.sh
index adaebbd748948c700c6717c2c6ad4d3cde1b6ac5..4c5b2e3f7078fadf6f70342ebca4bc1007af19f6 100755
--- a/scanLauncher.sh
+++ b/scanLauncher.sh
@@ -33,6 +33,14 @@ function check_value(){
     fi
 }
 
+# A few colors for echoing
+function darkblue(){
+    echo "\033[0;34m$1\033[0m"
+}
+function green(){
+    echo "\033[0;32m$1\033[0m"
+}
+
 ###### default ##############################
 dcsMonitor=false
 syncDatabases=false
@@ -61,6 +69,23 @@ check_value "-s" $scan
 if $dcsMonitor    ; then check_value "-d" $powersupplyConfig; fi
 if $syncDatabases ; then check_value "-t" $dbComConfig      ; fi
 
+localdbConf="$HOME/.yarr/localdb/localhost.localdomain_database.json"
+
+if $syncDatabases;
+then
+    jq -r  '.environment | keys[] as $k | "\($k) \(.[$k])"' $dbComConfig |
+    while IFS=" " read -r -a value; do
+        key=${value[0]}
+        val=${value[1]}
+
+        if [ "$(jq --arg v $val  '.environment | index( "\($v)" )' $localdbConf)" == "null" ]
+        then
+            jq --arg v $val  '.environment += ["\($v)"]' $localdbConf > tmp && mv tmp $localdbConf
+            echo -e "[ warn ][so] Added $(darkblue \"$val\") to \".environment\" in $localdbConf"
+        fi
+
+    done
+fi
 
 scanName=$(echo $scan | jq -r '.[0]')
 scanPath="$YARRBASE/configs/scans/rd53a/$scanName.json"
@@ -137,7 +162,7 @@ if [[ "$localdbOpt" != "" ]]; then
 
     if [ $dcsMonitor ] && ${syncDatabases} ;then
 
-        cmd="$YARRBASE/bin/dbAccessor -F $(readlink -f $dbComConfig) -n $module_id -s $SOBASE/data/$SO_RUNNUMBER/${RunNumber}_$scanName/scanLog.json -d $(readlink -f $dbComConfig)"
+        cmd="$YARRBASE/bin/dbAccessor -F $(readlink -f $dbComConfig) -n $module_id -s $SOBASE/data/$SO_RUNNUMBER/${RunNumber}_$scanName/scanLog.json -d $localdbConf"
         echo "[ info ][sl] Pushing the DCS data to localDB"
         echo "[ info ][sl] $cmd"
         $cmd
@@ -145,7 +170,7 @@ if [[ "$localdbOpt" != "" ]]; then
 
     elif ! ${syncDatabases} ;then
 
-        cmd="$YARRBASE/bin/dbAccessor -F \$1 -n $module_id -s $SOBASE/data/$SO_RUNNUMBER/${RunNumber}_$scanName/scanLog.json -d \$1"
+        cmd="$YARRBASE/bin/dbAccessor -F \$1 -n $module_id -s $SOBASE/data/$SO_RUNNUMBER/${RunNumber}_$scanName/scanLog.json -d $localdbConf"
         echo "$cmd" >> $SOBASE/data/$SO_RUNNUMBER/moveDCStoLocalDB.sh
 
     fi