diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignExample/CMakeLists.txt b/MuonSpectrometer/MuonAlignment/MuonAlignExample/CMakeLists.txt
index 3dc534182868612b8b76c0a4e1286077ec029e51..e881464cf6cbf988cce4cbf8ecbd2b8d67a0a9ec 100644
--- a/MuonSpectrometer/MuonAlignment/MuonAlignExample/CMakeLists.txt
+++ b/MuonSpectrometer/MuonAlignment/MuonAlignExample/CMakeLists.txt
@@ -6,7 +6,7 @@
 atlas_subdir( MuonAlignExample )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/*.py )
 #atlas_install_runtime( test/MuonAlignExample_TestConfiguration.xml )
 
diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/DefaultFiles.py b/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/DefaultFiles.py
index a5176849b0cc94176c51e240bcc489c6898a91f4..6835f4d711a15f8b289bac0644d2674b76e0238a 100644
--- a/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/DefaultFiles.py
+++ b/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/DefaultFiles.py
@@ -2,7 +2,6 @@
 
 from __future__ import print_function
 
-import os
 import glob
 import sys
 from socket import gethostname
@@ -57,7 +56,6 @@ class Files:
                 sshCmd="ssh "+scpHost+" ls "+inputPath
                 process = subprocess.Popen(sshCmd, shell=True, stdout=subprocess.PIPE)
                 output = process.communicate()
-                status=process.poll()
 
                 outputstring = output[0]
                 if outputstring == '':
@@ -173,7 +171,7 @@ class Files:
         filepy += ".py"
         
         filesOut = open(filepy,"w")        
-        filesOut.write("inputFile = "+filestring+"\n");
+        filesOut.write("inputFile = "+filestring+"\n")
         filesOut.close()
 
         return filepy
@@ -282,15 +280,6 @@ class DefaultFiles (Files):
             #nfiles = 2
             datasetdef = 'data10_7TeV.*.physics_MuonswBeam.merge.DESD_SGLMU.r1299*p165*_00'
 
-        #elif name=="periodD":
-        #    inputFilePath = ["/data/periodD/data10_7TeV.00165956.physics_Muons.merge.TAG.r1647_p306_p307_tid185039_00/"]
-        #    scpHost       = 'terrier10'
-        #    geometry      = ''
-        #    fileType      = 'TAG'
-        #    nfiles        = 10
-        #    datasetdef    = 'data10_7TeV.periodD.physics_MuonswBeam.*.ESD.repro*'
-        #    inputTagDef   = 'data10_7TeV.periodD.physics_MuonswBeam.*.TAG.repro*'
-
         elif name=="periodD":
             inputFilePath = ["/castor/cern.ch/grid/atlas/tzero/prod1/perm/data10_7TeV/physics_Muons/0165956/data10_7TeV.00165956.physics_Muons.merge.TAG.f294_m614_m613/"]
             scpHost       = ''
@@ -298,7 +287,6 @@ class DefaultFiles (Files):
             fileType      = 'TAG'
             nfiles        = 10
             datasetdef    = 'data10_7TeV.periodD.physics_MuonswBeam.*.ESD.repro*'
-            inputTagDef   = 'data10_7TeV.periodD.physics_MuonswBeam.*.TAG.repro*'
 
         elif name=="107206.singlepart_mu5.recon.ESD.e488_s634_s633_r870":
             inputFilePath = ["/tmp/roberth/mc09_valid.107206.singlepart_mu5.recon.ESD.e488_s634_s633_r870_tid099863"]
diff --git a/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/ScriptWriter.py b/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/ScriptWriter.py
index 2d0674ccfb0ef3707e8814b8506dd5bc7ee6e680..9bd7529d6c4ea1ec430ee0a11b2d43eed16f3345 100644
--- a/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/ScriptWriter.py
+++ b/MuonSpectrometer/MuonAlignment/MuonAlignExample/python/ScriptWriter.py
@@ -10,7 +10,7 @@ standard_library.install_aliases()
 import subprocess
 
 #from IOFiles import IOFiles
-from Jobs import JobThread,LocalJobList,SgeJobList,LxbatchJobList,PathenaJobList,PbsJobList
+from Jobs import SgeJobList,PathenaJobList,PbsJobList
 
 #-----------------------------------------------------------------------
 class ScriptWriter:
@@ -102,7 +102,6 @@ class ScriptWriter:
         jobrun.write(self.copyInputMatrixFilesStr())
 
         doSolve=1
-        asztOutputDir=self.IterPath
         
         # get athena command
         athCommandStr=self.athenaCommandStr(inputDataMap,doSolve)
@@ -247,7 +246,7 @@ class ScriptWriter:
     
     def createTmpDirStr(self,tmpdir,jobName):
         retstring = "RUNDIR=%s\"/run_%s\"\n" % (tmpdir,jobName)
-        retstring += "RUNDIR=${RUNDIR}\"_\"$(date +\%Y\%m\%d_\%H\%M\%S)\n"
+        retstring += "RUNDIR=${RUNDIR}\"_\"$(date +%%Y%%m%%d_%%H%%M%%S)\n"
         retstring += "mkdir -p $RUNDIR\n"
         retstring += "cd $RUNDIR\n"
         retstring += "echo 'RUNDIR='`pwd`\n\n"
@@ -277,12 +276,7 @@ class ScriptWriter:
             if iterator.doSolve:
                 inputAsztFileOrig += '_Solve'
             inputAsztFileOrig += '.txt'
-        if inputAsztFileOrig!='':
-            inputAsztFileDest = iterator.rootName
-            #if (iter>0 and iterator.doLevel1):
-            #    inputAsztFileDest += iterator.getString(iter-1,iCPU)
-            #inputAsztFileDest +=
-            #retstr += "cp %s %s\n" % (inputAsztFileOrig,inputAsztFileDest)         
+        if inputAsztFileOrig!='':       
             retstr += "cp %s %s\n" % (inputAsztFileOrig,"asztInput.txt") 
  
         self.extInputFiles.append("asztInput.txt")
@@ -455,7 +449,7 @@ class ScriptWriter:
         if (iterator.runMode!='pathena' and iterator.runMode!='prun') or doSolve:
             jobstring += execstring
 
-        elif (not doSolve or iterator.solveLocally==False):
+        elif (iterator.solveLocally is False or not doSolve):
 
             doESD=False
             if iterator.runargsJobOption.find('ESD')!=-1:
@@ -541,7 +535,7 @@ class ScriptWriter:
             print ("no prun exec!")
             return
         retstr ="\nrm -f runathena.sh"
-        retstr+="\necho \"athena.py -c \'inputFile=\\\"\'\$1\'\\\".split(\\\",\\\")\' "+self.execString+"\" > runathena.sh\n"
+        retstr+="\necho \"athena.py -c \'inputFile=\\\"\'\\$1\'\\\".split(\\\",\\\")\' "+self.execString+"\" > runathena.sh\n"
         print ("retstr: ",retstr)
 
         return retstr
@@ -598,8 +592,6 @@ class ScriptWriter:
         retstr += "mv %s %s\n"   % ("hitmap.bin",self.MatrixDir+'hitmap_'+self.JobName+'.bin')
         retstr += "mv %s %s\n"   % ("hitmap.txt",self.MatrixDir+'hitmap_'+self.JobName+'.txt')
         if self.iteration == 0:
-            outputEventList = "goodEvts_" + self.iterator.rootName + \
-                self.iterator.getString(self.iteration,-1) + '.txt'
             eventListOrig = "goodEvts_" + self.iterator.rootName + \
                 self.iterator.getString(0,self.iCPU) + '.txt'
             retstr += "mv %s %s%s\n" % ("goodEvts.txt",self.IterPath,eventListOrig)
@@ -610,7 +602,6 @@ class ScriptWriter:
     def getPathenaOutputStr(self):
 
         iterator = self.iterator
-        iter     = self.iteration
 
         dsdef = iterator.outputDatasetDef
 
@@ -627,11 +618,6 @@ class ScriptWriter:
         # rename to expected names and move to current directory        
         if not iterator.doBinariesOnly:
             jobstr += "mv %s*log.tgz %s.\n\n" % (dsdef,self.LogDir)
-            
-        rootFile = "MuonAlign_%s.root"  % self.JobName
-
-        outputEventList = "goodEvts_" + iterator.rootName + \
-            iterator.getString(iter,-1) + ".txt"
         
         jobstr += "mv *.EXT3.*.%s* %s/.\n\n" % \
             ("matrix.bin",self.MatrixDir) 
@@ -659,56 +645,11 @@ class ScriptWriter:
                 ("vector.txt",self.MatrixDir) 
 
             jobstr += "mv *.EXT8.*.%s* %s/.\n\n" % \
-                ("hitmap.txt",self.MatrixDir) 
-                
-            eventListOrig = "goodEvts_" + iterator.rootName + \
-                iterator.getString(0,job) + '.txt'
+                ("hitmap.txt",self.MatrixDir)
                 
             jobstr += "mv *.EXT9.*.%s* %s/.\n\n" % \
                 ("goodEvts.txt",self.IterPath) 
 
-        """
-        for job in range(0,iterator.nCPUs):
-            self.setCPU(iter,job)
-
-            jobindex = "%05d" % (job+1)
-
-            jobstr += "mv %s.EXT3._%s.%s %s%s%s%s\n\n" % \
-                ("*",jobindex,"matrix.bin",self.MatrixDir,"matrix_",self.JobName,".bin") 
-
-            jobstr += "mv %s.EXT5._%s.%s %s%s%s%s\n\n" % \
-                ("*",jobindex,"vector.bin",self.MatrixDir,"vector_",self.JobName,".bin") 
-
-            jobstr += "mv %s.EXT7._%s.%s %s%s%s%s\n\n" % \
-                ("*",jobindex,"hitmap.bin",self.MatrixDir,"hitmap_",self.JobName,".txt") 
-            
-            if not iterator.doBinariesOnly:
-                jobstr += "mv %s.EXT0._%s.%s %s%s\n\n" % \
-                    ("*",jobindex,"asztOutput.txt",self.IterPath,self.AsztOutput) 
-                
-                jobstr += "mv %s.EXT1._%s.%s %s%s\n\n" % \
-                    ("*",jobindex,'alignlogfile.txt',self.LogDir,self.JobName+".alglog")
-                
-                jobstr += "mv %s.EXT2._%s.%s %s%s\n\n" % \
-                    ("*",jobindex,'Align.root',self.IterPath,rootFile) 
-
-                jobstr += "mv %s.EXT4._%s.%s %s%s%s%s\n\n" % \
-                    ("*",jobindex,"matrix.txt",self.MatrixDir,"matrix_",self.JobName,".txt") 
-
-                jobstr += "mv %s.EXT6._%s.%s %s%s%s%s\n\n" % \
-                    ("*",jobindex,"vector.txt",self.MatrixDir,"vector_",self.JobName,".txt") 
-
-                jobstr += "mv %s.EXT8._%s.%s %s%s%s%s\n\n" % \
-                    ("*",jobindex,"hitmap.txt",self.MatrixDir,"hitmap_",self.JobName,".bin") 
-                
-                eventListOrig = "goodEvts_" + iterator.rootName + \
-                    iterator.getString(0,job) + '.txt'
-                
-                jobstr += "mv %s.EXT9._%s.%s %s%s\n\n" % \
-                    ("*",jobindex,"goodEvts.txt",self.IterPath,eventListOrig) 
-                """
-
-
         return jobstr
           
     def cleanupStr(self):
@@ -727,8 +668,6 @@ class ScriptWriter:
             print ("Error: filetype should be matrix, vector, or hitmap, exiting...")
             sys.exit()
 
-        jobName  = self.JobName            
-
         print ("MatrixDir: ",self.MatrixDir)
         import glob
         print ("looking for: ",self.MatrixDir+"*"+filetype+"*bin*")
diff --git a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/CMakeLists.txt b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/CMakeLists.txt
index 7891f175cc222ce18ae6049c04012e30f0e774b7..2a0f0e9d318b82dc3a82f16804e4d4333ab8923d 100644
--- a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/CMakeLists.txt
+++ b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/CMakeLists.txt
@@ -16,6 +16,6 @@ atlas_add_component( CscCalibAlgs
                      LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaBaseComps AthContainers StoreGateLib SGtests GaudiKernel CscCalibData CscCalibToolsLib MuonCSC_CnvToolsLib MuonCondInterface MuonCondData MuonReadoutGeometry MuonIdHelpersLib MuonRDO )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/*.py )
 
diff --git a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRun.py b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRun.py
index 1f61f07cfd708ee098ee176fe9e92a3658b33be5..27c967f573798344f111e4c0c6ffca1c8e714b38 100644
--- a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRun.py
+++ b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRun.py
@@ -56,11 +56,7 @@ class BulkRun :
       if(pattern != ""):
         #have files to run on
         runNumbers += [runNumber]
-        try:
-          self.RunAthena(pattern,runNumber)
-        except:
-          "Failure during RunAthena!"
-          raise
+        self.RunAthena(pattern,runNumber)
       else:
         print ("No more unprocessed files. Congrats!")
         print ("N runs done: " + str(runCnt +1))
@@ -78,13 +74,10 @@ class BulkRun :
 
     ProcessedFiles = []
 
-    try:
-      #Get processed files
-      f = open(self.ProcessedFilesList,"rb") 
-      ProcessedFiles = pickle.load(f)
-      f.close()
-    except:
-      print ("No processed file list yet...")
+    #Get processed files
+    f = open(self.ProcessedFilesList,"rb") 
+    ProcessedFiles = pickle.load(f)
+    f.close()
      
     #Remove newline character from each filename
 
@@ -160,10 +153,7 @@ class BulkRun :
     outputDirPath = self.OutputDirBase + "/" + runNumber
       
     if(self.AllowDirOverwrite):
-      try:
-        subprocess.call("rm -rf " + outputDirPath)
-      except:
-        pass
+      subprocess.call("rm -rf " + outputDirPath)
 
     print ("Making directory" + outputDirPath)
     #Create output directory
@@ -184,22 +174,18 @@ class BulkRun :
     #Output log file
     logFile = open(outputDirPath + "/run.log","w")
 
-    try:
-      print()
-      print ("**************************************")
-      print ("Starting running on run " + str(runNumber))
-      sys.stdout.flush()
-      subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
-      print ("Finished run " + str(runNumber))
-      print ("**************************************")
-      print()
-    except:
-      print ("Error while running athena!")
-      raise
+    print()
+    print ("**************************************")
+    print ("Starting running on run " + str(runNumber))
+    sys.stdout.flush()
+    subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
+    print ("Finished run " + str(runNumber))
+    print ("**************************************")
+    print()
 
     logFile.close()
 
 
     #Add files we just ran on to file list
-    newProcessedFiles = glob(pattern);
+    newProcessedFiles = glob(pattern)
     self.AddProcessedFiles(newProcessedFiles)
diff --git a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRunFollowup.py b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRunFollowup.py
index 436a03fc428a03bd5f2d5c837cc53662c5d1d98f..bf6734704471c3ecae9a0d696ca13bf6f6f0d50d 100644
--- a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRunFollowup.py
+++ b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/BulkRunFollowup.py
@@ -61,16 +61,12 @@ class BulkRunFollowup :
         #have files to run on
         if runNumber in self.AllowedRuns:
           runNumbers += [runNumber]
-          try:
-            self.RunAthena(pattern,runNumber)
-          except:
-            "Failure during RunAthena!"
-            raise
+          self.RunAthena(pattern,runNumber)
         else:
           if(self.debug):
             print ("Skipping file from runNumber " + str(runNumber) + " (Not allowed)")
           #Add files we're skipping into file list
-          newProcessedFiles = glob(pattern);
+          newProcessedFiles = glob(pattern)
           self.AddProcessedFiles(newProcessedFiles)
 
       else:
@@ -90,19 +86,10 @@ class BulkRunFollowup :
 
     ProcessedFiles = []
 
-    try:
-      #Get processed files
-      f = open(self.ProcessedFilesList,"rb") 
-      ProcessedFiles = pickle.load(f)
-      f.close()
-    except:
-      print ("No processed file list yet...")
-     
-    #Remove newline character from each filename
-
-    #for index in range(len(ProcessedFiles)) : 
-    #  file = ProcessedFiles[index]
-    #  ProcessedFiles[index] = file[0:len(file)-1] 
+    #Get processed files
+    f = open(self.ProcessedFilesList,"rb") 
+    ProcessedFiles = pickle.load(f)
+    f.close()
 
     print ('Processed String: ')
     print (ProcessedFiles)
@@ -140,8 +127,6 @@ class BulkRunFollowup :
       print()
       print ("Searching for file")
       print ("InputPattern: " + self.InputPattern)
-      #print ("inputFiles: ")
-      #print (inputFiles)
 
     pattern = ""
     runNumber = ""
@@ -178,19 +163,12 @@ class BulkRunFollowup :
     outputDirPath = self.OutputDirBase + "/" + runNumber
       
     if(self.AllowDirOverwrite):
-      try:
-        subprocess.call("rm -rf " + outputDirPath)
-      except:
-        pass
+      subprocess.call("rm -rf " + outputDirPath)
 
     print ("Making directory" + outputDirPath)
     #Create output directory
     os.mkdir(outputDirPath,0o755)
 
-    #Change directory to output directory
-    #(Causes problems)
-    #os.chdir(outputDirPath)
-
     #Athena options
     athOpt = "outputPre='" + outputDirPath +"/" + runNumber 
     athOpt += "';inputPat='" + pattern 
@@ -203,22 +181,17 @@ class BulkRunFollowup :
     #Output log file
     logFile = open(outputDirPath + "/run2.log","w")
 
-    try:
-      print()
-      print ("**************************************")
-      print ("Starting running on run " + str(runNumber))
-      sys.stdout.flush()
-      subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
-      print ("Finished run " + str(runNumber))
-      print ("**************************************")
-      print()
-    except:
-      print ("Error while running athena!")
-      raise
+    print()
+    print ("**************************************")
+    print ("Starting running on run " + str(runNumber))
+    sys.stdout.flush()
+    subprocess.Popen(athArgs,stdout=logFile,stderr=subprocess.STDOUT).wait()
+    print ("Finished run " + str(runNumber))
+    print ("**************************************")
+    print()
 
     logFile.close()
 
-
     #Add files we just ran on to file list
-    newProcessedFiles = glob(pattern);
+    newProcessedFiles = glob(pattern)
     self.AddProcessedFiles(newProcessedFiles)
diff --git a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/CscCalibQuery.py b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/CscCalibQuery.py
index e87468c8ae727b578d99819d6ba21bcf011d9c5d..08c810520581381206f1a354d39ad9f71f36a049 100755
--- a/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/CscCalibQuery.py
+++ b/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/CscCalibQuery.py
@@ -254,29 +254,19 @@ def runCalib(calType, runNumber,workDir,castorCopyCmd):
 
 print ('running'  )
 #first command line argument should be the calibration type, pulser or ped.
-try:
-  calType = sys.argv[1]
-  if calType == 'pulser':
-    calibFileDir = '/castor/cern.ch/user/l/lampen/CalibRunTest/slope/'
-    oldListFilePath = '/afs/cern.ch/user/m/muoncali/CSC/run/pulserList.txt'
-    outputDir = '/afs/cern.ch/user/m/muoncali/w0/CSC/runs/pulser/pulser'
-  elif calType == 'ped':
-    calibFileDir = '/castor/cern.ch/grid/atlas/DAQ/muon/csc/'
-    oldListFilePath = '/afs/cern.ch/user/m/muoncali/CSC/run/pedDirList.txt'
-
-    #oldListFilePath = '/afs/cern.ch/user/l/lampen/Calib/dev/rel_0/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/pedList.txt'
-    #outputDir = '/afs/cern.ch/user/l/lampen/Calib/dev/rel_0/MuonSpectrometer/MuonCalib/CscCalib/CscCalibAlgs/python/'
-    outputDir = '/afs/cern.ch/user/m/muoncali/w0/CSC/runs/ped/ped'
-    #data11_calib.00172807.calibration_pedCSC.daq.RAW._lb0000._CSC-EB._0001.data
-    #calibRe = re.compile('data10_calib.*calibration_ped\.daq\.RAQ.*\.data')
-    #calibRe = re.compile('data10_.*pedCSC.*\.data')
-    calibRe = re.compile('data1.*_calib.*calibration_pedCSC\.daq\.RAW.*\.data')
-  else:
-    print ('Need to specify pulser or ped')
-    os._exit(0)
-except:
+calType = sys.argv[1]
+if calType == 'pulser':
+  calibFileDir = '/castor/cern.ch/user/l/lampen/CalibRunTest/slope/'
+  oldListFilePath = '/afs/cern.ch/user/m/muoncali/CSC/run/pulserList.txt'
+  outputDir = '/afs/cern.ch/user/m/muoncali/w0/CSC/runs/pulser/pulser'
+elif calType == 'ped':
+  calibFileDir = '/castor/cern.ch/grid/atlas/DAQ/muon/csc/'
+  oldListFilePath = '/afs/cern.ch/user/m/muoncali/CSC/run/pedDirList.txt'
+  outputDir = '/afs/cern.ch/user/m/muoncali/w0/CSC/runs/ped/ped'
+  calibRe = re.compile('data1.*_calib.*calibration_pedCSC\\.daq\\.RAW.*\\.data')
+else:
   print ('Need to specify pulser or ped')
-  os._exit(0) 
+  os._exit(0)
 
 
 #First, see if a calibration is already running
@@ -365,10 +355,10 @@ if(oldLs != currentLs):
               print ("There is a calib dir, but it only has " + str(nFiles)
                      + " file. Will not process.")
               updateRunList = False
-            break;
+            break
           if(ThisCalibDir):
             fullPath = calibFileDir + DirName + '/' + fileName 
-            castorCopyCmd += "\nxrdcp root://castoratlas/" + fullPath + " ${bytestreamDir}";
+            castorCopyCmd += "\nxrdcp root://castoratlas/" + fullPath + " ${bytestreamDir}"
             #print ('found ' + fullPath)
           else:
             break
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/CMakeLists.txt b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/CMakeLists.txt
index dde11a41e37fef0534499e90c1fbdec8bdc13f85..cd4539773d4c536aef028e77a1680e306b04973d 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/CMakeLists.txt
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/CMakeLists.txt
@@ -25,7 +25,7 @@ atlas_add_component( MuonCalibDbOperations
                      LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} AthenaBaseComps GaudiKernel MdtCalibUtils MuonCalibStandAloneBaseLib AthenaKernel StoreGateLib SGtests MdtCalibData MdtCalibRt MuonCalibIdentifier MuonCalibMath MuonReadoutGeometry MuonIdHelpersLib MuonCalibDbOperationsLib z )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/*.py )
 atlas_install_scripts( share/CalibDbCompareRT.py share/CalibDbCompareT0.py share/CalibDbDump.py share/CalibCoolCompareT0.py share/CalibCoolCompareRT.py share/CalibDbCool2Calib.py share/calibdata.py )
 
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationDefaultSourceConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationDefaultSourceConfig.py
index 89a6b6b3384e922a1fb6b55634d57e782cb59561..578dc90547ee5eda2594525bcf7781a76f504898 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationDefaultSourceConfig.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationDefaultSourceConfig.py
@@ -1,6 +1,6 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
-from MuonCalibDbOperations.MuonCalibDbOperationsConf import MuonCalib__CoolInserter,MuonCalib__MuonCalibDefaultCalibrationSource
+from MuonCalibDbOperations.MuonCalibDbOperationsConf import MuonCalib__MuonCalibDefaultCalibrationSource
 
 class MuonCalib__CalibrationDefaultSourceConfig:
 	
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationSourceConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationSourceConfig.py
index 839d6dd137c7a16a40102a0cc25687daf1b59174..9dcb9eb5a7fd9967e17a66bd9cb61caf33825356 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationSourceConfig.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationSourceConfig.py
@@ -4,8 +4,6 @@ from __future__ import print_function
 
 import sys
 from MuonCalibDbOperations.MuonCalibDbOperationsConf import MuonCalib__MuonCalibDbCalibrationSource
-import cx_Oracle
-
 
 MuonCalib__gCalibrationSourceConfigs = []
 
@@ -15,7 +13,7 @@ class MuonCalib__CalibrationSourceConfig:
 
 	def __init__(self, site_name, head_id, region="", store_rt=True, store_t0=True):
 		
-		if not site_name in self.__working_schemata:
+		if site_name not in self.__working_schemata:
 			print ("FATAL: unknown site name ", site_name)
 			print ("FATAL: must be one of", self.__working_schemata.keys())
 			sys.exit(1)
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationTargetFolderConfig.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationTargetFolderConfig.py
index 5ce82634b85ecb0c3ff5b2e53bb665f99fad4838..a6638e6fbb614148969183c5b624abac5d04e2c7 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationTargetFolderConfig.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/CalibrationTargetFolderConfig.py
@@ -3,7 +3,6 @@
 from __future__ import print_function
 
 import sys
-from PyCool import cool,coral
 import CoolConvUtilities.AtlCoolLib as AtlCoolLib
 from MuonCalibDbOperations.MuonCalibResolveTag import ResolveTag
 
@@ -13,7 +12,7 @@ MuonCalib__gCalibrationTargetConfigs = []
 class MuonCalib__CalibrationTargetConfig:
 
 	def __init__(self, FolderType="T0"):
-		if not FolderType in ["T0", "RT", "T0BLOB", "RTBLOB"]:
+		if FolderType not in ["T0", "RT", "T0BLOB", "RTBLOB"]:
 			print ("FATAL Folder type must be 'T0[BLOB]' or 'RT[BLOB]'")
 			sys.exit(1)
 
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/MuonCalibResolveTag.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/MuonCalibResolveTag.py
index 73f4ce2243b9bb335deca7f4a1422c5a0a8053ff..dbbc1e5ff5db1c7d2f540a9fe30b3df992644e6e 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/MuonCalibResolveTag.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/MuonCalibResolveTag.py
@@ -5,9 +5,8 @@ from __future__ import print_function
 def ResolveTag(folder, tag):
 	theTag=tag
 	if tag.upper() in ['NEXT', 'CURRENT']:
-		from PyCool import cool
 		import sys
-		if not '/afs/cern.ch/user/a/atlcond/utils/python/' in sys.path:
+		if '/afs/cern.ch/user/a/atlcond/utils/python/' not in sys.path:
 			sys.path.append('/afs/cern.ch/user/a/atlcond/utils/python/')
 		from AtlCoolBKLib import resolveAlias
 		if tag.upper()=="NEXT":
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCalibDb.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCalibDb.py
index c535686c04fd0ff5e971609de2d9dbed8425be4d..5adc4cbe44cc5ff3a0c28907b5854c7f0836057c 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCalibDb.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCalibDb.py
@@ -1,13 +1,13 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
-import cx_Oracle
-from MuonCalibIdentifier.MuonFixedIdUnpack import *
+from MuonCalibIdentifier.MuonFixedIdUnpack import MuonFixedIdUnpack
 import CalibDbInfo
 import sys
+import cx_Oracle
 
 sys.argv=[sys.argv[0], '-b']
 
-from ROOT import *
+from ROOT import TGraph, TSpline3
 
 
 def get_data_schema(cursor, db, head_id):
@@ -32,7 +32,7 @@ def build_rt_relation(r,t, rt_id):
 def ReadRtCalibDb(db, reader_passwd, head_id):
 	ra = CalibDbInfo.dbr[CalibDbInfo.calibdb]
 	tns = CalibDbInfo.tns[CalibDbInfo.calibdb]
-	if reader_passwd == None:
+	if not reader_passwd:
 		reader_passwd = CalibDbInfo.dbr_password[CalibDbInfo.calibdb]
 	connection=cx_Oracle.connect(ra, reader_passwd, tns)
 	cursor=connection.cursor()
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py
index 21c9458ba0c3925eaf444305721b383e38bde70d..a26c385cdafa38a562914dbd61d5f882a5f736f2 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py
@@ -8,12 +8,12 @@ import zlib,StringIO
 import sys
 import re
 from MuonCalibDbOperations.MuonCalibResolveTag import ResolveTag
-from MuonCalibDbOperations.MuonCalibConvertTimeSlewing import *	
+from MuonCalibDbOperations.MuonCalibConvertTimeSlewing import TimeSlewingApplied, NoTs2Ts, GasmonDriftTimeOffsetT0
 	
 sys.argv=[sys.argv[0], '-b']
 
-from ROOT import *
-from MuonCalibIdentifier.MuonFixedIdUnpack import *
+from ROOT import TGraphErrors, TSpline3, gDirectory
+from MuonCalibIdentifier.MuonFixedIdUnpack import MuonFixedIdUnpack
 
 def UnpackData(data):
 	if type(data)==str:
@@ -60,7 +60,7 @@ def DumpFolderSummary(db_string, folder, tag, run=None):
 		if TimeSlewingApplied(obj):
 			ts="TS"		
 		ident=(obj.since()>>32, obj.until()>>32, site, head_id, ts)
-		if not ident in counters:
+		if ident not in counters:
 			counters[ident] = 0
 		counters[ident] +=1
 	for ident in sorted(counters.keys(), key=iov_keygen):
diff --git a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/genGasmonSource.py b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/genGasmonSource.py
index 26ea291828d72113c17404b6f6c201ec63ff932f..1feea91227aeeed7f41e43284247fce98cb74e2e 100644
--- a/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/genGasmonSource.py
+++ b/MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/genGasmonSource.py
@@ -3,11 +3,9 @@
 from __future__ import print_function
 
 import sys
-from MuonCalibDbOperations.CalibrationSourceConfig import *
-import cx_Oracle
+from MuonCalibDbOperations.CalibrationSourceConfig import MuonCalib__gCalibrationSourceConfigs, MuonCalib__CalibrationSourceConfig
 import time
 
-
 def MuonCalib__genGasmonSource(toroidOn, cal_time, reader_cursor):
 	if len(MuonCalib__gCalibrationSourceConfigs)==0 and not time:
 		print ("FATAL Cannot generate gasmon source if no time and no other calibration sources are given")
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/CMakeLists.txt b/MuonSpectrometer/MuonCnv/MuonCnvExample/CMakeLists.txt
index a67290f4def96ed8cfaa5b2e1a6dccd14dcc2917..f45a629b66186c98b56b266ce10af92c2c8b2039 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/CMakeLists.txt
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/CMakeLists.txt
@@ -6,7 +6,7 @@
 atlas_subdir( MuonCnvExample )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/*.py )
 atlas_install_runtime( share/*.data )
 
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
index 501fb4da7460869b0a6fd016c4beb47a1adfbb97..119051b449d1b8c4b874eba5b4d69c88b8c2c56a 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
@@ -8,7 +8,6 @@ from AthenaCommon.GlobalFlags import globalflags
 from MuonByteStream.MuonByteStreamFlags import muonByteStreamFlags
 from AthenaCommon.AppMgr import theApp,ToolSvc,ServiceMgr
 from AthenaCommon.DetFlags import DetFlags
-from RecExConfig.RecFlags import rec as recFlags
 from MuonCnvExample.MuonCnvFlags import muonCnvFlags
 
 from AthenaCommon.AlgSequence import AthSequencer
@@ -39,10 +38,9 @@ if DetFlags.readRDOBS.RPC_on() or DetFlags.readRDOPool.RPC_on() or DetFlags.read
             muonCnvFlags.RpcCablingMode = 'new'
         else:
             log.info("No RPC cabling taginfo found. Using normal configuration.")
-    except:
+    except KeyError:
         log.info("No metadata/Taginfo found. Using normal configuration for RPC")
-    log.info("RPC cabling is using mode: %s" % muonCnvFlags.RpcCablingMode())
-    
+    log.info("RPC cabling is using mode: %s",muonCnvFlags.RpcCablingMode())
     from MuonCablingServers.MuonCablingServersConf import RPCcablingServerSvc
     ServiceMgr += RPCcablingServerSvc()
     theApp.CreateSvc += [ "RPCcablingServerSvc" ] # TODO: Remove once the C++ dependencies are fixed
@@ -50,10 +48,8 @@ if DetFlags.readRDOBS.RPC_on() or DetFlags.readRDOPool.RPC_on() or DetFlags.read
     ServiceMgr.RPCcablingServerSvc.forcedUse=True
     ServiceMgr.RPCcablingServerSvc.useMuonRPC_CablingSvc=True #Needed to switch to new cabling
 
-    from MuonRPC_Cabling.MuonRPC_CablingConf import MuonRPC_CablingSvc
-    # ServiceMgr += MuonRPC_CablingSvc()
-    import MuonRPC_Cabling.MuonRPC_CablingConfig
-    # ServiceMgr.MuonRPC_CablingSvc.OutputLevel = 3
+    # without the following line, the MuonRPC_CablingSvc is not part of the ServiceMgr, thus add flake8 ignore flag
+    import MuonRPC_Cabling.MuonRPC_CablingConfig # noqa: F401
     ServiceMgr.MuonRPC_CablingSvc.RPCTriggerRoadsfromCool=True
     from IOVDbSvc.CondDB import conddb
     #
@@ -89,7 +85,7 @@ if DetFlags.readRDOBS.RPC_on() or DetFlags.readRDOPool.RPC_on() or DetFlags.read
     condSequence += RpcCablingCondAlg("RpcCablingCondAlg")
 
 if DetFlags.readRDOBS.TGC_on() or DetFlags.readRDOPool.TGC_on() or DetFlags.readRIOPool.TGC_on() or DetFlags.digitize.TGC_on():
-    log.info("TGC cabling is using mode: %s" % muonCnvFlags.TgcCablingMode())
+    log.info("TGC cabling is using mode: %s",muonCnvFlags.TgcCablingMode())
     
     from MuonCablingServers.MuonCablingServersConf import TGCcablingServerSvc
     ServiceMgr += TGCcablingServerSvc()
@@ -130,7 +126,7 @@ if DetFlags.readRDOBS.TGC_on() or DetFlags.readRDOPool.TGC_on() or DetFlags.read
         #conddb.addFolder("TGC_OFL","/TGC/TRIGGER/CW_TILE") 
 
 if DetFlags.readRDOBS.MDT_on() or DetFlags.readRDOPool.MDT_on()  or DetFlags.readRIOPool.MDT_on() or DetFlags.digitize.MDT_on():
-    log.info("MDT cabling is using mode: %s" % muonCnvFlags.MdtCablingMode())
+    log.info("MDT cabling is using mode: %s",muonCnvFlags.MdtCablingMode())
 
     #Set up new cabling.
     from MuonMDT_Cabling.MuonMDT_CablingConf import MuonMDT_CablingSvc
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibConfig.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibConfig.py
index 084fcafe75514875a4ef86fe05ef969cb1087310..27abbdb6b0f62785b41f6f8fa5542fbdd6d04e02 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibConfig.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibConfig.py
@@ -6,11 +6,10 @@
 
 from AthenaCommon.Logging import logging
 logging.getLogger().info("Importing %s", __name__)
+logMuon = logging.getLogger(__name__)
 
 from AthenaCommon.GlobalFlags import globalflags
-from AthenaCommon.BeamFlags import jobproperties
-beamFlags = jobproperties.Beam
-from AthenaCommon.BFieldFlags import jobproperties
+from AthenaCommon.JobProperties import jobproperties
 from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
 from AthenaCommon import CfgMgr
 #--------------------------------------------------------------
@@ -107,7 +106,8 @@ def setupCscCondDB():
 
 
 def CscCalibTool(name,**kwargs):
-    import MuonCondAlg.CscCondDbAlgConfig # MT-safe conditions access
+    # without the following line, the CscCondDbAlg is not scheduled, thus add flake8 ignore flag
+    import MuonCondAlg.CscCondDbAlgConfig # noqa: F401
     # make tool
     return CfgMgr.CscCalibTool(
         Slope=0.19,
@@ -194,7 +194,7 @@ def MdtCalibrationTool(name="MdtCalibrationTool", **kwargs):
     kwargs.setdefault("DoWireSagCorrection", mdtCalibFlags.correctMdtRtWireSag())
 
     # for collisions cut away hits that are far outside of the MDT time window
-    if beamFlags.beamType() == 'collisions':
+    if jobproperties.Beam.beamType() == 'collisions':
         kwargs.setdefault("DoTofCorrection", True)
 
         if globalflags.DataSource() == 'geant4' or globalflags.DataSource() == 'data':
@@ -218,7 +218,9 @@ def MdtCalibrationDbTool(name="MdtCalibrationDbTool", **kwargs):
 
 # return a list of dictionaires containing the calib config info (keys etc)
 def getCalibConfigs():
-    global muonRecFlags,rec
+    from MuonRecExample.MuonRecFlags import muonRecFlags
+    from RecExConfig import RecFlags as rec
+    from MuonRecExample import ConfiguredMuonRec as muonRec
     configs = []
     if muonRecFlags.calibMuonStandalone and (muonRecFlags.doStandalone or rec.readESD):
 #        try:
@@ -236,15 +238,17 @@ def getCalibConfigs():
 ## Setup MuonSegmenToCalibSegment algorithm.
 # @param[in] segmentKeys list of segment keys to use or single segments key (string)
 def getMuonSegmentToCalibSegment():
-    global topSequence,muonRecFlags
+    from MuonRecExample.MuonRecFlags import muonRecFlags
+    from AthenaCommon.AppMgr import topSequence
     try:
         return topSequence.MuonSegmentToCalibSegment
     except AttributeError:
-            
+        from AthenaCommon.CfgGetter import getPublicTool
         from MuonCalibPatRec.MuonCalibPatRecConf import MuonCalib__MuonSegmentToCalibSegment
         MuonSegmentToCalibSegment = MuonCalib__MuonSegmentToCalibSegment("MuonSegmentToCalibSegment")
         # set consistent time-of-flight correction with MdtDriftCircleOnTrackCreator
         mdtCreator = getPublicTool("MdtDriftCircleOnTrackCreator")
+        from AthenaCommon.ConfiguredFactory import getProperty
         MuonSegmentToCalibSegment.DoTOF = getProperty(mdtCreator,"DoTofCorrection")
         # when doing segment fits with floating t0's
         MuonSegmentToCalibSegment.UpdateForT0Shift = type(MuonSegmentToCalibSegment.getDefaultProperty("UpdateForT0Shift")) (muonRecFlags.doSegmentT0Fit())
@@ -268,7 +272,9 @@ def getMuonSegmentToCalibSegment():
 # depending on the use-case.
 # @param[in] evenTag The event tag written to file
 def getMuonCalibAlg(eventTag):
-    global topSequence,beamFlags
+    from AthenaCommon.AppMgr import topSequence
+    from MuonRecExample.MuonRecFlags import muonRecFlags
+    from RecExConfig import RecFlags as rec
     try:
         return topSequence.MuonCalibAlg
     except AttributeError:
@@ -284,7 +290,7 @@ def getMuonCalibAlg(eventTag):
                                                NtupleName = muonRecFlags.calibNtupleOutput(),  # set the name of the output calibration ntuple
                                                EventTag = eventTag )
 
-        if beamFlags.beamType == 'singlebeam' or beamFlags.beamType == 'cosmics':
+        if jobproperties.Beam.beamType() == 'singlebeam' or jobproperties.Beam.beamType() == 'cosmics':
             MuonCalibAlg.addTriggerTag = False
         else:
             MuonCalibAlg.addTriggerTag = rec.doTrigger()
@@ -294,358 +300,130 @@ def getMuonCalibAlg(eventTag):
 
 
 def setupMuonCalibNtuple():
-    global topSequence,muonRecFlags,beamFlags,ToolSvc,rec,DetFlags
+    from MuonRecExample.MuonRecFlags import muonRecFlags
+    from AthenaCommon.DetFlags import DetFlags
+    from RecExConfig import RecFlags as rec
+    from AthenaCommon.AppMgr import topSequence
+    from AthenaCommon.AppMgr import ToolSvc
     if not rec.doMuon() or not DetFlags.Muon_on():
         logMuon.warning("Not setting up requested Muon Calibration Ntuple because Muons are off")
         return
     
     logMuon.info("Setting up Muon Calibration Ntuple")
-    try:
-        configs = getCalibConfigs()
-        # MuonSegmentToCalibSegment is only needed if we want segments
-        if muonRecFlags.calibNtupleSegments and muonRecFlags.calibMuonStandalone:
-            MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()
-
-        # MuonCalibAlg is always needed
-        eventTag="UNKNOWN"
-        if (muonRecFlags.calibNtupleSegments or muonRecFlags.calibNtupleTracks) and muonRecFlags.calibMuonStandalone:
-            if len(configs) >= 1:
-                eventTag = configs[0]["eventTag"]
-        elif muonRecFlags.calibNtupleTrigger:
-            eventTag = "TRIG"
-        else:
-            eventTag = "HITS"
-
-        MuonCalibAlg = getMuonCalibAlg(eventTag)
-        # configure for writing ntuple
-        from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
-        MuonCalibTool = MuonCalib__PatternNtupleMaker("MuonCalibPatternNtupleMaker")
-        MuonCalibTool.FillTruth = rec.doTruth()
-        MuonCalibTool.DoRawTGC = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC())
-        ToolSvc += MuonCalibTool
-        MuonCalibAlg.MuonCalibTool = MuonCalibTool
-
-        # MuonCalibExtraTree only if we want to write tracks
-        if muonRecFlags.calibNtupleTracks:
-            MuonCalibTool.DelayFinish = True
-            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
-            MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg("MuonCalibExtraTreeAlg",
-                                                                     NtupleName = "PatternNtupleMaker",
-                                                                     )
-            segmentOnTrackSelector=None
-            if hasattr(topSequence, "MuonSegmentToCalibSegment"):
-              from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__SegmentOnTrackSelector
-              segmentOnTrackSelector=MuonCalib__SegmentOnTrackSelector()
-              segmentOnTrackSelector.PattternLocation = "PatternsForCalibration"
-              ToolSvc+=segmentOnTrackSelector
-              MuonCalibExtraTreeAlg.SegmentOnTrackSelector= segmentOnTrackSelector
-            if not rec.doMuonCombined():
-               tool_nr=0
-               from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__ExtraTreeTrackFillerTool
-               resPullCalc=getPublicTool("ResidualPullCalculator")
-               for config in configs:
-                 trackDumpTool = MuonCalib__ExtraTreeTrackFillerTool("ExtraTreeTrackFillerTool" + str(tool_nr))
-                 trackDumpTool.TrackCollectionKey = config['tracksKey']
-                 trackDumpTool.SegmentAuthors = [config['segmentAuthor']]
-                 trackDumpTool.TrackAuthor = config['trackAuthor']
-                 trackDumpTool.PullCalculator = resPullCalc
-                 ToolSvc+=trackDumpTool
-                 MuonCalibExtraTreeAlg.TrackFillerTools.append(trackDumpTool)
-                 tool_nr+=1
-            # configure needed tools
-
-
-            # add to topSequence
-            topSequence += MuonCalibExtraTreeAlg
-
-
-        # MuonCalibExtraTreeTriggerAlg only if trigger is available
-        if muonRecFlags.calibNtupleTrigger: # and DetFlags.detdescr.LVL1_on() and DetFlags.haveRDO.LVL1_on():
-            # protect against running without AtlasTrigger project
-            doMuCTPI = True
-            if doMuCTPI:
-                try:
-                    from TrigT1RPCRecRoiSvc import TrigT1RPCRecRoiConfig
-                    from TrigT1TGCRecRoiSvc import TrigT1TGCRecRoiConfig
-                except ImportError:
-                    logMuon.warning("MuonCalibExtraTreeTriggerAlg.doMuCTPI = False because AtlasTrigger is not available")
-                    doMuCTPI = False
-
-            # delay writing of MuonCalibAlg
-            MuonCalibTool.DelayFinish = True
-            # also delay MuonCalibExtraTreeAlg if it is running
-            try:
-                topSequence.MuonCalibExtraTreeAlg.DelayFinish = True
-            except AttributeError:
-                pass
-            
-            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeTriggerAlg
-            topSequence += MuonCalib__MuonCalibExtraTreeTriggerAlg( 'MuonCalibExtraTreeTriggerAlg',
-                                                                    doMuCTPI   = doMuCTPI,
-                                                                    doLVL1Calo = rec.doTile() or rec.doLArg() or DetFlags.haveRDO.Calo_on(),
-                                                                    doMBTS     = rec.doTile() or DetFlags.haveRDO.Tile_on() )
-
-
-    except:
-        from AthenaCommon.Resilience import treatException
-        treatException("Problem in MuonCalib - Muon Calibration Ntuple configuration probably incomplete")
-
-
-
-def setupMuonCalib():
-    global topSequence,ToolSvc
-    if not rec.doMuon() or not DetFlags.Muon_on():
-        logMuon.warning("Not setting up requested Muon Calibration because Muons are off")
-        return
-
-    logMuon.info("Setting up Muon Calibration")
-    try:
-        from MuonCnvExample.MuonCalibFlags import muonCalibFlags
-        muonCalibFlags.setDefaults()
-
-        configs = getCalibConfigs()
-        #
-        # MuonSegmentToCalibSegment
-        #
-        calibConfig = muonRec.allConfigs()[0].getCalibConfig() #muonRec.getConfig(muonCalibFlags.EventTag()).getCalibConfig()
-        MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()
-        #
-        # MuonCalibAlg
-        #
-        MuonCalibAlg = getMuonCalibAlg(muonCalibFlags.EventTag())
-
-        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
-        MuonCalibTool = MuonCalib__MdtCalibTool()
-        calibMode = muonCalibFlags.Mode()
-        if calibMode == 'regionNtuple':
-            from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
-            MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
-        else:
-            raise RuntimeError( "Unknown Muon Calibration Mode: %r" % calibMode )
-
-        ToolSvc += MdtCalibTool
-        MuonCalibTool.MdtCalibTool = MdtCalibTool
-
-        ToolSvc += MuonCalibTool
-        MuonCalibAlg.MuonCalibTool = MuonCalibTool
-    except:
-        from AthenaCommon.Resilience import treatException
-        treatException("Problem in MuonCalib - Muon Calibration configuration probably incomplete")
-
-
-# return a list of dictionaires containing the calib config info (keys etc)
-def getCalibConfigs():
-    global muonRecFlags,rec
-    configs = []
-    if muonRecFlags.calibMuonStandalone and (muonRecFlags.doStandalone or rec.readESD):
-#        try:
-            configs.append( muonRec.getConfig("MuonStandalone").getCalibConfig() )
-#        except KeyError:
-#            logMuon.warning("Could not get calibration config for MuonStandAlone - not adding MuonStandAlone info to calibration")
-#            muonRecFlags.calibMuonStandalone = False
+    configs = getCalibConfigs()
+    # MuonSegmentToCalibSegment is only needed if we want segments
+    if muonRecFlags.calibNtupleSegments and muonRecFlags.calibMuonStandalone:
+        getMuonSegmentToCalibSegment()
+
+    # MuonCalibAlg is always needed
+    eventTag="UNKNOWN"
+    if (muonRecFlags.calibNtupleSegments or muonRecFlags.calibNtupleTracks) and muonRecFlags.calibMuonStandalone:
+        if len(configs) >= 1:
+            eventTag = configs[0]["eventTag"]
+    elif muonRecFlags.calibNtupleTrigger:
+        eventTag = "TRIG"
     else:
-        muonRecFlags.calibMuonStandalone = False
-
-    return configs
+        eventTag = "HITS"
+
+    MuonCalibAlg = getMuonCalibAlg(eventTag)
+    # configure for writing ntuple
+    from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
+    MuonCalibTool = MuonCalib__PatternNtupleMaker("MuonCalibPatternNtupleMaker")
+    MuonCalibTool.FillTruth = rec.doTruth()
+    MuonCalibTool.DoRawTGC = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC())
+    ToolSvc += MuonCalibTool
+    MuonCalibAlg.MuonCalibTool = MuonCalibTool
+
+    # MuonCalibExtraTree only if we want to write tracks
+    if muonRecFlags.calibNtupleTracks:
+        MuonCalibTool.DelayFinish = True
+        from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
+        MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg("MuonCalibExtraTreeAlg",
+                                                                 NtupleName = "PatternNtupleMaker",
+                                                                 )
+        segmentOnTrackSelector=None
+        if hasattr(topSequence, "MuonSegmentToCalibSegment"):
+          from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__SegmentOnTrackSelector
+          segmentOnTrackSelector=MuonCalib__SegmentOnTrackSelector()
+          segmentOnTrackSelector.PattternLocation = "PatternsForCalibration"
+          ToolSvc+=segmentOnTrackSelector
+          MuonCalibExtraTreeAlg.SegmentOnTrackSelector= segmentOnTrackSelector
+        if not rec.doMuonCombined():
+           tool_nr=0
+           from AthenaCommon.CfgGetter import getPublicTool
+           from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__ExtraTreeTrackFillerTool
+           resPullCalc=getPublicTool("ResidualPullCalculator")
+           for config in configs:
+             trackDumpTool = MuonCalib__ExtraTreeTrackFillerTool("ExtraTreeTrackFillerTool" + str(tool_nr))
+             trackDumpTool.TrackCollectionKey = config['tracksKey']
+             trackDumpTool.SegmentAuthors = [config['segmentAuthor']]
+             trackDumpTool.TrackAuthor = config['trackAuthor']
+             trackDumpTool.PullCalculator = resPullCalc
+             ToolSvc+=trackDumpTool
+             MuonCalibExtraTreeAlg.TrackFillerTools.append(trackDumpTool)
+             tool_nr+=1
+        # configure needed tools
+
+
+        # add to topSequence
+        topSequence += MuonCalibExtraTreeAlg
+
+
+    # MuonCalibExtraTreeTriggerAlg only if trigger is available
+    if muonRecFlags.calibNtupleTrigger: # and DetFlags.detdescr.LVL1_on() and DetFlags.haveRDO.LVL1_on():
+
+        # delay writing of MuonCalibAlg
+        MuonCalibTool.DelayFinish = True
+        # also delay MuonCalibExtraTreeAlg if it is running
+        try:
+            topSequence.MuonCalibExtraTreeAlg.DelayFinish = True
+        except AttributeError:
+            pass
         
-    
-
-## Setup MuonSegmenToCalibSegment algorithm.
-# @param[in] segmentKeys list of segment keys to use or single segments key (string)
-def getMuonSegmentToCalibSegment():
-    global topSequence,muonRecFlags
-    try:
-        return topSequence.MuonSegmentToCalibSegment
-    except AttributeError:
-            
-        from MuonCalibPatRec.MuonCalibPatRecConf import MuonCalib__MuonSegmentToCalibSegment
-        MuonSegmentToCalibSegment = MuonCalib__MuonSegmentToCalibSegment("MuonSegmentToCalibSegment")
-        # set consistent time-of-flight correction with MdtDriftCircleOnTrackCreator
-        mdtCreator = getPublicTool("MdtDriftCircleOnTrackCreator")
-        MuonSegmentToCalibSegment.DoTOF = getProperty(mdtCreator,"DoTofCorrection")
-        # when doing segment fits with floating t0's
-        MuonSegmentToCalibSegment.UpdateForT0Shift = type(MuonSegmentToCalibSegment.getDefaultProperty("UpdateForT0Shift")) (muonRecFlags.doSegmentT0Fit())
-        MuonSegmentToCalibSegment.UseCscSegments = False
-        MuonSegmentToCalibSegment.SegmentLocations = [ "MuonSegments" ]
-        MuonSegmentToCalibSegment.SegmentAuthors = [ 4,8 ] 
-        MuonSegmentToCalibSegment.ReadSegments = True # rather than SegmentCombinations
-
-        from MuonCnvExample import MuonCalibConfig
-        MuonCalibConfig.setupMdtCondDB()
-
-        MuonSegmentToCalibSegment.CalibrationTool = MuonCalibConfig.MdtCalibrationTool()
-
-        # finally add it to topSequence
-        topSequence += MuonSegmentToCalibSegment
-
-    return topSequence.MuonSegmentToCalibSegment
-
-
-## Setup the basic MuonCalibAlg algorithm. Needs further configuration after this call
-# depending on the use-case.
-# @param[in] evenTag The event tag written to file
-def getMuonCalibAlg(eventTag):
-    global topSequence,beamFlags
-    try:
-        return topSequence.MuonCalibAlg
-    except AttributeError:
-        from MuonCalibAlgs.MuonCalibAlgsConf import MuonCalib__MuonCalibAlg
-        MuonCalibAlg = MuonCalib__MuonCalibAlg("MuonCalibAlg",
-                                               doMDTs = muonRecFlags.doMDTs(),
-                                               doCSCs = muonRecFlags.doCSCs(),
-                                               doRPCs = muonRecFlags.doRPCs(),
-                                               doTGCs = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC()),
-                                               doTGCCoinData = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC()),
-                                               doTruth = rec.doTruth(),
-                                               DoPrdSelect = muonRecFlags.doPrdSelect(),  # optional cutting away of PRD hits to simulate dead channels
-                                               NtupleName = muonRecFlags.calibNtupleOutput(),  # set the name of the output calibration ntuple
-                                               EventTag = eventTag )
-
-        if beamFlags.beamType == 'singlebeam' or beamFlags.beamType == 'cosmics':
-            MuonCalibAlg.addTriggerTag = False
-        else:
-            MuonCalibAlg.addTriggerTag = rec.doTrigger()
-        MuonCalibAlg.doTruth=rec.doTruth()
-        topSequence += MuonCalibAlg
-        return topSequence.MuonCalibAlg
-
-
-def setupMuonCalibNtuple():
-    global topSequence,muonRecFlags,beamFlags,ToolSvc,rec,DetFlags
-    if not rec.doMuon() or not DetFlags.Muon_on():
-        logMuon.warning("Not setting up requested Muon Calibration Ntuple because Muons are off")
-        return
-    
-    logMuon.info("Setting up Muon Calibration Ntuple")
-    try:
-        configs = getCalibConfigs()
-        # MuonSegmentToCalibSegment is only needed if we want segments
-        if muonRecFlags.calibNtupleSegments and muonRecFlags.calibMuonStandalone:
-            MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()
-
-        # MuonCalibAlg is always needed
-        eventTag="UNKNOWN"
-        if (muonRecFlags.calibNtupleSegments or muonRecFlags.calibNtupleTracks) and muonRecFlags.calibMuonStandalone:
-            if len(configs) >= 1:
-                eventTag = configs[0]["eventTag"]
-        elif muonRecFlags.calibNtupleTrigger:
-            eventTag = "TRIG"
-        else:
-            eventTag = "HITS"
-
-        MuonCalibAlg = getMuonCalibAlg(eventTag)
-        # configure for writing ntuple
-        from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
-        MuonCalibTool = MuonCalib__PatternNtupleMaker("MuonCalibPatternNtupleMaker")
-        MuonCalibTool.FillTruth = rec.doTruth()
-        MuonCalibTool.DoRawTGC = (muonRecFlags.doTGCs() and muonRecFlags.calibNtupleRawTGC())
-        ToolSvc += MuonCalibTool
-        MuonCalibAlg.MuonCalibTool = MuonCalibTool
-
-        # MuonCalibExtraTree only if we want to write tracks
-        if muonRecFlags.calibNtupleTracks:
-            MuonCalibTool.DelayFinish = True
-            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
-            MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg("MuonCalibExtraTreeAlg",
-                                                                     NtupleName = "PatternNtupleMaker",
-                                                                     )
-            segmentOnTrackSelector=None
-            if hasattr(topSequence, "MuonSegmentToCalibSegment"):
-              from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__SegmentOnTrackSelector
-              segmentOnTrackSelector=MuonCalib__SegmentOnTrackSelector()
-              segmentOnTrackSelector.PattternLocation = "PatternsForCalibration"
-              ToolSvc+=segmentOnTrackSelector
-              MuonCalibExtraTreeAlg.SegmentOnTrackSelector= segmentOnTrackSelector
-            if not rec.doMuonCombined():
-               tool_nr=0
-               from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__ExtraTreeTrackFillerTool
-               resPullCalc=getPublicTool("ResidualPullCalculator")
-               for config in configs:
-                 trackDumpTool = MuonCalib__ExtraTreeTrackFillerTool("ExtraTreeTrackFillerTool" + str(tool_nr))
-                 trackDumpTool.TrackCollectionKey = config['tracksKey']
-                 trackDumpTool.SegmentAuthors = [config['segmentAuthor']]
-                 trackDumpTool.TrackAuthor = config['trackAuthor']
-                 trackDumpTool.PullCalculator = resPullCalc
-                 ToolSvc+=trackDumpTool
-                 MuonCalibExtraTreeAlg.TrackFillerTools.append(trackDumpTool)
-                 tool_nr+=1
-            # configure needed tools
-
-
-            # add to topSequence
-            topSequence += MuonCalibExtraTreeAlg
-
-
-        # MuonCalibExtraTreeTriggerAlg only if trigger is available
-        if muonRecFlags.calibNtupleTrigger: # and DetFlags.detdescr.LVL1_on() and DetFlags.haveRDO.LVL1_on():
-            # protect against running without AtlasTrigger project
-            doMuCTPI = True
-            if doMuCTPI:
-                try:
-                    from TrigT1RPCRecRoiSvc import TrigT1RPCRecRoiConfig
-                    from TrigT1TGCRecRoiSvc import TrigT1TGCRecRoiConfig
-                except ImportError:
-                    logMuon.warning("MuonCalibExtraTreeTriggerAlg.doMuCTPI = False because AtlasTrigger is not available")
-                    doMuCTPI = False
-
-            # delay writing of MuonCalibAlg
-            MuonCalibTool.DelayFinish = True
-            # also delay MuonCalibExtraTreeAlg if it is running
-            try:
-                topSequence.MuonCalibExtraTreeAlg.DelayFinish = True
-            except AttributeError:
-                pass
-            
-            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeTriggerAlg
-            topSequence += MuonCalib__MuonCalibExtraTreeTriggerAlg( 'MuonCalibExtraTreeTriggerAlg',
-                                                                    doMuCTPI   = doMuCTPI,
-                                                                    doLVL1Calo = rec.doTile() or rec.doLArg() or DetFlags.haveRDO.Calo_on(),
-                                                                    doMBTS     = rec.doTile() or DetFlags.haveRDO.Tile_on() )
-
-
-    except:
-        from AthenaCommon.Resilience import treatException
-        treatException("Problem in MuonCalib - Muon Calibration Ntuple configuration probably incomplete")
+        from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeTriggerAlg
+        topSequence += MuonCalib__MuonCalibExtraTreeTriggerAlg( 'MuonCalibExtraTreeTriggerAlg',
+                                                                doMuCTPI   = True,
+                                                                doLVL1Calo = rec.doTile() or rec.doLArg() or DetFlags.haveRDO.Calo_on(),
+                                                                doMBTS     = rec.doTile() or DetFlags.haveRDO.Tile_on() )
 
 
 
 def setupMuonCalib():
-    global topSequence,ToolSvc
+    from RecExConfig import RecFlags as rec
+    from AthenaCommon.AppMgr import ToolSvc
+    from AthenaCommon.DetFlags import DetFlags
     if not rec.doMuon() or not DetFlags.Muon_on():
         logMuon.warning("Not setting up requested Muon Calibration because Muons are off")
         return
 
     logMuon.info("Setting up Muon Calibration")
-    try:
-        from MuonCnvExample.MuonCalibFlags import muonCalibFlags
-        muonCalibFlags.setDefaults()
-
-        configs = getCalibConfigs()
-        #
-        # MuonSegmentToCalibSegment
-        #
-        calibConfig = muonRec.allConfigs()[0].getCalibConfig() #muonRec.getConfig(muonCalibFlags.EventTag()).getCalibConfig()
-        MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()
-        #
-        # MuonCalibAlg
-        #
-        MuonCalibAlg = getMuonCalibAlg(muonCalibFlags.EventTag())
-
-        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
-        MuonCalibTool = MuonCalib__MdtCalibTool()
-        calibMode = muonCalibFlags.Mode()
-        if calibMode == 'regionNtuple':
-            from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
-            MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
-        else:
-            raise RuntimeError( "Unknown Muon Calibration Mode: %r" % calibMode )
+    from MuonCnvExample.MuonCalibFlags import muonCalibFlags
+    muonCalibFlags.setDefaults()
+
+    getCalibConfigs()
+    #
+    # MuonSegmentToCalibSegment
+    #
+    from MuonRecExample import ConfiguredMuonRec as muonRec
+    muonRec.allConfigs()[0].getCalibConfig() #muonRec.getConfig(muonCalibFlags.EventTag()).getCalibConfig()
+    getMuonSegmentToCalibSegment()
+    #
+    # MuonCalibAlg
+    #
+    MuonCalibAlg = getMuonCalibAlg(muonCalibFlags.EventTag())
+
+    from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
+    MuonCalibTool = MuonCalib__MdtCalibTool()
+    calibMode = muonCalibFlags.Mode()
+    if calibMode == 'regionNtuple':
+        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
+        MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
+    else:
+        raise RuntimeError( "Unknown Muon Calibration Mode: %r" % calibMode )
 
-        ToolSvc += MdtCalibTool
-        MuonCalibTool.MdtCalibTool = MdtCalibTool
+    ToolSvc += MdtCalibTool
+    MuonCalibTool.MdtCalibTool = MdtCalibTool
 
-        ToolSvc += MuonCalibTool
-        MuonCalibAlg.MuonCalibTool = MuonCalibTool
+    ToolSvc += MuonCalibTool
+    MuonCalibAlg.MuonCalibTool = MuonCalibTool
 
-    except:
-        from AthenaCommon.Resilience import treatException
-        treatException("Problem in MuonCalib - Muon Calibration configuration probably incomplete")
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py
index 702c7e8af9c5ceb0f332ac8244379d2bd707bf73..c5ff3e83e1016d4885ca067a20deb733d3177011 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCalibFlags.py
@@ -4,9 +4,8 @@ from AthenaCommon.Logging import logging
 logging.getLogger().info("Importing module %s",__name__)
 
 from AthenaCommon.JobProperties import JobProperty,JobPropertyContainer,jobproperties
-from AthenaCommon.GlobalFlags import globalflags
-from AthenaCommon.BeamFlags import jobproperties
-beamFlags = jobproperties.Beam
+import AthenaCommon.BeamFlags
+beamFlags = AthenaCommon.BeamFlags.jobproperties.Beam
 
 from MuonCnvExample.MuonCnvUtils import setJobPropertyDefault
 logMuon = logging.getLogger(__name__)
@@ -19,7 +18,8 @@ def setDefault(prop,value):
 ################################################################################
 class MdtCalib(JobPropertyContainer):
     def setDefaults(self):
-        global globalflags,beamFlags
+        global beamFlags
+        from AthenaCommon.GlobalFlags import globalflags
         if globalflags.DataSource == 'data' and beamFlags.beamType == 'collisions':
             setDefault(self.correctMdtRtForBField,True)
         else:
@@ -240,7 +240,7 @@ class MuonCalib(JobPropertyContainer):
                     if oldValue:
                         self.Mode = newflag
                         # print a deprecated warning
-                        log.warning( '%s flag is deprecated. Use muonCalibFlags.Mode = %r instead (%s)',
+                        logMuon.warning( '%s flag is deprecated. Use muonCalibFlags.Mode = %r instead (%s)',
                                      oldflag, newflag,
                                      'from ' + __name__ + ' import muonCalibFlags' )
 
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvExampleConfigDb.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvExampleConfigDb.py
index e5afa5b8fb6409c9c57a15eac3e0aec35f706f49..82a7cbd101a869de93cd30af6ee28adb64c06c44 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvExampleConfigDb.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvExampleConfigDb.py
@@ -1,6 +1,6 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
-from AthenaCommon.CfgGetter import addTool, addToolClone, addService, addAlgorithm
+from AthenaCommon.CfgGetter import addTool, addService, addAlgorithm
 
 ################################################################################
 # Standard BS algorithms
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvFlags.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvFlags.py
index 9e9611f98c7dedc828f94936a24f0584210beed3..da7345cff210e940907de7a72701d35da3a1611b 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvFlags.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCnvFlags.py
@@ -1,15 +1,11 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from AthenaCommon.Logging import logging
 logging.getLogger().info("Importing %s", __name__)
 
-from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
 from AthenaCommon.DetFlags import DetFlags
 from AthenaCommon.JobProperties import JobProperty,JobPropertyContainer,jobproperties
-from AthenaCommon.GlobalFlags import globalflags
-from AthenaCommon.DetFlags import DetFlags
-from RecExConfig.RecFlags import rec as recFlags
-import re 
+import re
 logMuon = logging.getLogger(__name__)
 
 from MuonCnvExample.MuonCnvUtils import setJobPropertyDefault
@@ -37,6 +33,7 @@ class MuonCnv(JobPropertyContainer):
 #                else:
 #                    setDefault(self.MdtCablingMode, 'auto')
 
+        from AthenaCommon.GlobalFlags import globalflags
 
         # RPC
         if globalflags.InputFormat.is_bytestream() and globalflags.DataSource() == 'geant4':
diff --git a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonReadBSConfig.py b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonReadBSConfig.py
index 30a246695cbd5660b6b82e789ac5b6f017434c8c..c74325471414eb54a7e8334d186744ff2bdc7d4b 100644
--- a/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonReadBSConfig.py
+++ b/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonReadBSConfig.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from AthenaCommon.DetFlags import DetFlags
 from AthenaCommon.AppMgr import ServiceMgr
@@ -6,10 +6,6 @@ from AthenaCommon import CfgMgr
 from OverlayCommonAlgs.OverlayFlags import overlayFlags
 
 if DetFlags.readRDOBS.Muon_on():
-    # the following 'if' is crucial to not break online, which user their own ByteStreamCnvSvc
-    if not hasattr(ServiceMgr,"ByteStreamCnvSvc"):
-        from ByteStreamCnvSvc import ReadByteStream
-
     if not hasattr( ServiceMgr, "ByteStreamAddressProviderSvc" ):
         from ByteStreamCnvSvcBase. ByteStreamCnvSvcBaseConf import ByteStreamAddressProviderSvc
         ServiceMgr += ByteStreamAddressProviderSvc()
@@ -20,7 +16,6 @@ if DetFlags.readRDOBS.Muon_on():
 
 def MdtROD_Decoder(name="MdtROD_Decoder",**kwargs):
     # setup cabling service needed by this tool
-    from . import MuonCablingConfig
     return CfgMgr.MdtROD_Decoder(name,**kwargs)
 
 
@@ -40,7 +35,6 @@ def MdtRawDataProviderTool(name="MdtRawDataProviderTool",**kwargs):
     
 def RpcROD_Decoder(name="RpcROD_Decoder",**kwargs):
     # setup cabling service needed by this tool
-    from . import MuonCablingConfig
     return CfgMgr.Muon__RpcROD_Decoder(name,**kwargs)
 
 
@@ -60,7 +54,6 @@ def RpcRawDataProviderTool(name = "RpcRawDataProviderTool",**kwargs):
 
 def TgcROD_Decoder(name = "TgcROD_Decoder",**kwargs):
     # setup cabling service needed by this tool
-    from . import MuonCablingConfig
     return CfgMgr.Muon__TGC_RodDecoderReadout(name,**kwargs)
 
 
diff --git a/MuonSpectrometer/MuonG4/MuonG4SD/CMakeLists.txt b/MuonSpectrometer/MuonG4/MuonG4SD/CMakeLists.txt
index b01fdcaebfc1dccc922bc2c65c6cdf707e4d3a2f..49674eb97eab255fb745b28249aec3cc612f190d 100644
--- a/MuonSpectrometer/MuonG4/MuonG4SD/CMakeLists.txt
+++ b/MuonSpectrometer/MuonG4/MuonG4SD/CMakeLists.txt
@@ -80,5 +80,5 @@ atlas_add_test( sTGCSensitiveDetector_gtest
                 LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} ${GTEST_LIBRARIES} TestTools MuonG4SDLib StoreGateLib SGtests GeoPrimitives GaudiKernel MuonSimEvent G4AtlasToolsLib MCTruth )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 atlas_install_joboptions( share/optionForTest.txt )
diff --git a/MuonSpectrometer/MuonG4/MuonG4SD/python/MuonG4SDConfig.py b/MuonSpectrometer/MuonG4/MuonG4SD/python/MuonG4SDConfig.py
index 5bbb723dc026b7770be259892cf9f47c05add321..b3733cf165ff59758b2b2277679cce529b095409 100644
--- a/MuonSpectrometer/MuonG4/MuonG4SD/python/MuonG4SDConfig.py
+++ b/MuonSpectrometer/MuonG4/MuonG4SD/python/MuonG4SDConfig.py
@@ -83,7 +83,7 @@ def getRPCSensitiveDetectorCosmics(name="RPCSensitiveDetectorCosmics", **kwargs)
                                                               merger_input_property,
                                                               region)
     kwargs.setdefault("LogicalVolumeNames", ["Muon::gazGap"])
-    kwargs.setdefault("OutputCollectionNames", [bare_collection_name])
+    kwargs.setdefault("OutputCollectionNames", [hits_collection_name])
     return CfgMgr.RPCSensitiveDetectorCosmicsTool(name, **kwargs)