diff --git a/build/lib/iexcode/init_xrays.py b/build/lib/iexcode/init_xrays.py
index ed42729f9b6aed1143e73352afd037b7d3ac6a4d..98461ccfd83b38d43373123ffd108cb0fe80cd60 100644
--- a/build/lib/iexcode/init_xrays.py
+++ b/build/lib/iexcode/init_xrays.py
@@ -1,4 +1,4 @@
-from iexcode.instruments.beamline import * 
+from iexcode.instruments.get_all import * 
 from iexcode.instruments.diagnostics import * 
 from iexcode.instruments.FMB_mirrors import * 
 from iexcode.instruments.gate_valves import * 
diff --git a/build/lib/iexcode/instruments/xrays.py b/build/lib/iexcode/instruments/xrays.py
index 7f70c3f2281809fb2aa8d9289581e15271e07ad3..64822c0b2e424e77a4ae80133c193fa6a27fc4e1 100644
--- a/build/lib/iexcode/instruments/xrays.py
+++ b/build/lib/iexcode/instruments/xrays.py
@@ -239,7 +239,7 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True):
 
         ID_energy_set(hv_eV,verbose=verbose)
         mono_energy_set(hv_eV,verbose=verbose)
-        slits_set_BL(c_2B=slit_coeff,c_1A=1,verbose=verbose)
+        apertures_set(c_2B=slit_coeff,c_1A=1,verbose=verbose)
 
         if m3r == True:
             if iex.BL.branch() == 'd':
@@ -331,7 +331,7 @@ def switch_gratings(grating):
         main_shutter_close()
         print("Switching grating, please wait...")
         mono_grating_translate(grating,quiet=True)
-        slits_set_BL()
+        apertures_set()
 
         if shutter_open:
             main_shutter_open()
@@ -399,7 +399,7 @@ def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kw
     if ID_offset != None:
         ID_energy_set = (start+stop)/2.0 + ID_offset
         
-    slits_set_BL()
+    apertures_set()
 
     mono_scan_fillin(mda,scan_dim,start,stop,step,**kwargs)
     
@@ -510,7 +510,7 @@ def scanXAS_BL(start_stop_step_lists,**kwargs):
         meshD("In")
      
     #Setting the beamline energy
-    slits_set_BL(mono_array[0],m3r=kwargs["m3r"])
+    apertures_set(mono_array[0],m3r=kwargs["m3r"])
 
     #mpa
     if BL.endstation == "Kappa" and kwargs["mcp"]:
diff --git a/build/lib/iexcode/macros/start_of_the_week.py b/build/lib/iexcode/macros/start_of_the_week.py
index ce69923b1f444649ca4fef215592bb4872e9a601..7ed0cd221a679dfedba817b040ea495fa82f0bd7 100644
--- a/build/lib/iexcode/macros/start_of_the_week.py
+++ b/build/lib/iexcode/macros/start_of_the_week.py
@@ -232,7 +232,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
                 sleep(1)
                 scan_narrow_slit('1H',[0.25, -3, 3, 0.1])
                 sleep(1)
-                slits_set_BL()
+                apertures_set()
                 m=BL.mda.lastFileNum()
                 try:
                     V1=fit_mda(m-1,detDiode,1,'gauss');plt.show()
@@ -254,7 +254,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
             flag=True
             while flag:
                 mono_energy_set(500)
-                slits_set_BL()
+                apertures_set()
                 n=2 if 'extended_range' in kwargs  else 1
                 scan_mono_vs_slit('2V',[0.25*c,-2*c*n,2*c*n,0.5],[475,515,2],comment='Mono/Slit - 2V')    #10/20 min for MEG/HEG
                 scan_mono_vs_slit('2H',[0.25,-2*n,2*n,0.5],[475,515,2],comment='Mono/Slit - 2H')    #10min
diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py
index 64dac150689ca44644197fbc2a342b792f80dc51..d57b89b579ce2715e99db5b49f94122e3cbc08f8 100644
--- a/iexcode/instruments/ARPES.py
+++ b/iexcode/instruments/ARPES.py
@@ -44,7 +44,7 @@ def ARPES_init(*userName,**kwargs):
     """
     kwargs.setdefault('scan_ioc',default_ioc)
     kwargs.setdefault('xrays',True)
-    kwargs.setdefault('BL_mode','user')
+    kwargs.setdefault('mode','user')
     kwargs.setdefault('set_folders',True)
     kwargs.setdefault('reset',True)
 
@@ -55,7 +55,7 @@ def ARPES_init(*userName,**kwargs):
     ARPES_Motors = Motors('ARPES',_ARPES_motor_dictionary(),physical_motors,psuedo_motors)
 
     #endstation
-    iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors)
+    iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],ARPES_Motors)
     iex.BL.safe_state = ARPES_safe_state
     iex.BL.endstation_get = ARPES_get_all
 
diff --git a/iexcode/instruments/IEX_endstations.py b/iexcode/instruments/IEX_endstations.py
index 49cfa3418f4c3a1752e135ec455fb93d6a5f1134..ce1abb4360967574c5593955bfa154539cbd6901 100644
--- a/iexcode/instruments/IEX_endstations.py
+++ b/iexcode/instruments/IEX_endstations.py
@@ -35,14 +35,14 @@ class Endstation:
 
     """
 
-    def __init__(self,endstation_name,scan_ioc,xrays,BL_mode,Motors=None,**kwargs):
+    def __init__(self,endstation_name,scan_ioc,xrays,mode='user',Motors=None,**kwargs):
         """
         intializes the several beamline variables 
 
         endstation_name = 'ARPES' / 'Kappa'
         
         BL = Endstation()
-            BL.endstation => endstation_name
+            BL.endstation_name => endstation_name
             BL.branch => BL branch 'c' or 'd' only (used for shutter checks)
             BL.xrays => True/False 
             BL.mode => 'user'/'staff' previously: BL_Mode_Set
@@ -59,7 +59,7 @@ class Endstation:
             
         """
        
-        self.endstation = None
+        self.endstation_name = None
         self.branch = None
         self.ioc = scan_ioc
         self.folder = None
@@ -69,7 +69,7 @@ class Endstation:
         self.xrays = xrays
 
         self.mda = ScanRecord(scan_ioc)
-        self.Motors = Motors
+        self.motors = Motors
 
         self.safe_state = None
         self.endstation_get = None
@@ -77,17 +77,17 @@ class Endstation:
         BL_mode_list = ['user','staff']
 
         if endstation_name in endstations_list:
-            self.endstation=endstation_name
+            self.endstation_name=endstation_name
         else:
             print('Not a valid Endstation choice')
             print('Endstations: '+endstations_list)
             return
 
         
-        if BL_mode in BL_mode_list:
+        if mode in BL_mode_list:
 
-            self.mode = BL_mode
-            if BL_mode == 'user':
+            self.mode = mode
+            if mode == 'user':
                 #For new endstation modify here:
                 if endstation_name == 'ARPES':
                     self.folder = 'c'
@@ -103,7 +103,7 @@ class Endstation:
                 else:
                     print('folder and prefix not set')
 
-            elif BL_mode == 'staff':
+            elif mode == 'staff':
                 #overwrite folder for staff mode
                 self.folder = 'b' 
                 self.prefix = endstation_name+"_"
diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py
index edd6198526d0c51d10ab84a0a6a2ab114971a209..eb6e593068ff13f7dd7cd1c89364e9ef751818eb 100644
--- a/iexcode/instruments/Kappa.py
+++ b/iexcode/instruments/Kappa.py
@@ -47,7 +47,7 @@ def Kappa_init(*userName,**kwargs):
      """
     kwargs.setdefault('scan_ioc',default_ioc)
     kwargs.setdefault('xrays',True)
-    kwargs.setdefault('BL_mode','user')
+    kwargs.setdefault('mode','user')
     kwargs.setdefault('set_folders',True)
     kwargs.setdefault('reset',True)
 
@@ -58,7 +58,7 @@ def Kappa_init(*userName,**kwargs):
     Kappa_Motors = Motors('Kappa',_Kappa_motor_dictionary(),physical_motors,psuedo_motors)
 
     #endstation
-    iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],Kappa_Motors)
+    iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],Kappa_Motors)
 
     #setting folders
     if kwargs['set_folders']:
diff --git a/iexcode/instruments/beamline.py b/iexcode/instruments/get_all.py
similarity index 96%
rename from iexcode/instruments/beamline.py
rename to iexcode/instruments/get_all.py
index d23df80732ec835298be39176ce35e93076a48d6..c23abbe7e450d8654addf04f1c33ab5a77b179d2 100644
--- a/iexcode/instruments/beamline.py
+++ b/iexcode/instruments/get_all.py
@@ -7,6 +7,7 @@ import iexcode.instruments.cfg as iex
 from iexcode.instruments.xrays import xrays_get_all
 
     
+
 def get_all(verbose=True):
     """
     returns the current beamline and endstation setting
@@ -24,5 +25,4 @@ def get_all(verbose=True):
     if verbose:
         print("\n===========================================================")
     
-    return vals
-    
\ No newline at end of file
+    return vals
\ No newline at end of file
diff --git a/iexcode/instruments/m3r.py b/iexcode/instruments/m3r.py
index 54bb5ec77693a6857ce71dd5b87d6b4aeffd3386..7a8f790e26a43711e85f3eddb6fab155762d6daf 100644
--- a/iexcode/instruments/m3r.py
+++ b/iexcode/instruments/m3r.py
@@ -119,8 +119,19 @@ def centroid(t=None,q=1):
         print('(position, sigma, total intensity, integration time (s), mirror pitch):')
     return position,sigma,intensity,t,m3rRY
 
-def m3r_align(pxl=None):
+def _m3r_align_start(pxl=None):
     if pxl == None:
         pxl = caget(M3R_align_pv+'desired_pixel')
     caput(M3R_align_pv+'desired_pixel',pxl)
     caput(M3R_align_pv+'startAlign',1,wait=True,timeout=180)
+
+def m3r_align(pxl=None):
+    if iex.BL.branch() == 'd':
+        print('\nalign_m3r()')
+        try:
+            _m3r_align_start()
+            sleep(1)
+            if m3r_RY_pos_sp_get() == m3r_RY_pos_sp():
+                _m3r_align_start()
+        except:
+            print('Unable to align; check camera settings.')
\ No newline at end of file
diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py
index 566a82d173ee791436f0253c1e1ff4187d3a8299..f3906939f61f05eba3a64222664b918498bc0d69 100644
--- a/iexcode/instruments/scanRecord.py
+++ b/iexcode/instruments/scanRecord.py
@@ -746,7 +746,11 @@ class ScanRecord:
                 stop  = caget(self.ioc+"scan"+str(i)+".P1EP")
                 step  = caget(self.ioc+"scan"+str(i)+".P1SI")
                 print('Scan'+str(i)+': '+drive+'= '+str(start)+' / '+str(stop)+' / '+str(step))
-        
+        try: 
+            if iex.BL.xrays:
+                shutter_check(verbose=True)
+        except:
+            print_warning_message('no shutter check')
         if self.check(scan_dim):
             filename = self.prefix()
             fileNum  = self.fileNum()
diff --git a/iexcode/instruments/shutters.py b/iexcode/instruments/shutters.py
index 39eb4da5630d605bd2eeece1d42095bcf94b64dc..ebeca3f54cc11355f8cdb4af343f71a985557946 100644
--- a/iexcode/instruments/shutters.py
+++ b/iexcode/instruments/shutters.py
@@ -12,14 +12,15 @@ from iexcode.instruments.utilities import dateandtime
 ################################             main shutter             ##############################
 ##############################################################################################################
 
-def main_shutter_open():
+def main_shutter_open(verbose=True):
     """
     opens the main shutter
 
     Previously: Open_MainShutter 
     """
     caput("PC:29ID:FES_OPEN_REQUEST.VAL",1, wait=True,timeout=180000)
-    print("Opening Main Shutter...")
+    if verbose:
+        print("Opening Main Shutter...")
 
 def main_shutter_close():
     """
@@ -28,7 +29,8 @@ def main_shutter_close():
     Previously: Close_MainShutter
     """
     caput("PC:29ID:FES_CLOSE_REQUEST.VAL",1,wait=True,timeout=18000)
-    print("Closing Main Shutter...")
+    if verbose:
+        print("Closing Main Shutter...")
 
 def main_shutter_status():
     """
@@ -68,15 +70,15 @@ def main_shutter_check_open():
 ################################             branch shutters            ##############################
 ##############################################################################################################
 
-def branch_shutter_status(verbose=False):
+def branch_shutter_status(branch=iex.BL.branch,verbose=False):
     """
     checks on the status of the main shutter
     and returns shutter_open = True / False
     """
-    pvA="PA:29ID:S"+iex.BL.branch+"S_BLOCKING_BEAM.VAL"
-    pvB="PB:29ID:S"+iex.BL.branch+"S_BLOCKING_BEAM.VAL"
+    pvA="PA:29ID:S"+branch+"S_BLOCKING_BEAM.VAL"
+    pvB="PB:29ID:S"+branch+"S_BLOCKING_BEAM.VAL"
     #"ON" = 1 => shutter open
-    status=caget(pvA)+caget(pvA)
+    status=caget(pvA)+caget(pvB)
     if status == 2:
         shutter_open=True
     else:
@@ -84,30 +86,30 @@ def branch_shutter_status(verbose=False):
 
     if verbose:
         status = 'Open' if shutter_open else 'Closed'
-        print(iex.BL.branch+"-shutter is "+status)
+        print(branch+"-shutter is "+status)
     return shutter_open
 
-def branch_shutter_close():
+def branch_shutter_close(branch=iex.BL.branch,verbose=False):
     """
     closes current branch shutter
 
     Previously: Close_BranchShutter
     """
-    caput("PC:29ID:S"+iex.BL.branch+"S_CLOSE_REQUEST.VAL",1,wait=True,timeout=18000)
-    print("Closing "+iex.BL.branch+"-Shutter...")
+    caput("PC:29ID:S"+branch+"S_CLOSE_REQUEST.VAL",1,wait=True,timeout=18000)
+    print("Closing "+branch+"-Shutter...")
 
 
-def branch_shutter_open():
+def branch_shutter_open(branch=iex.BL.branch,verbose=False):
     """
     Opens current branch shutter 
 
     Previoulsy: Open_BranchShutter
 
     """
-    shutter_status = branch_shutter_status
+    shutter_status = branch_shutter_status()
     if shutter_status:
-        print(iex.BL.branch+"-Shutter already open...")
+        print(branch+"-Shutter already open...")
     else:
-        caput("PC:29ID:S"+iex.BL.branch+"S_OPEN_REQUEST.VAL",1,wait=True,timeout=18000)
-        print("Opening "+iex.BL.branch+"-Shutter...")
+        caput("PC:29ID:S"+branch+"S_OPEN_REQUEST.VAL",1,wait=True,timeout=18000)
+        print("Opening "+branch+"-Shutter...")
         
\ No newline at end of file
diff --git a/iexcode/instruments/slits.py b/iexcode/instruments/slits.py
index 1b323e3ead9d82e35929bd013f277f8cfc7b3bd3..3aa8714d265b2ae2572ef76e7fe0baaed80e0585 100644
--- a/iexcode/instruments/slits.py
+++ b/iexcode/instruments/slits.py
@@ -5,8 +5,7 @@ from .IEX_endstations import *
 
 
 from iexcode.instruments.shutters import main_shutter_close
-from iexcode.instruments.utilities import print_warning_message, read_dict
-from iexcode.instruments.VLS_PGM import mono_get_all
+from iexcode.instruments.utilities import print_warning_message
 from iexcode.instruments.encoders import encoders_reset
 
 slit_ioc="29idb:"
@@ -463,47 +462,3 @@ def slit_3C_rbv():
     size=round(K0+K1*position+K2*position**2+K3*position**3+K4*position**4+K5*position**5+K6*position**6,0)
     return size, position
 
-##############################################################################################################
-################################             beamline slits            ##############################
-############################################################################################################## 
-
-def slits_set_BL(c_2B=1,c_1A=1,verbose=True):
-    """
-    Sets slit-1A and slit-2B for the current 
-    grating and photon energy to remove the heat bump
-
-    c_1A and c_2B are used to take a different ratio of the beam 
-    (1 = normal ops, < 1 to reduce flux)
-
-    Previously: SetSlit_BL
-    """
-    mono_vals=mono_get_all()
-    hv_rbv = mono_vals['ENERGY_MON']
-    grt  = mono_vals['GRT']
-    
-    # slit were defined for the range: 500 - 2000
-    hv = max(hv_rbv,500)
-    hv = min(hv_rbv,2000)
-    c = 4.2/2.2 # to account for the magnification difference between gratings
-
-    if grt == 'MEG':
-        V=0.65        #  set to 65% of RR calculation for both grt => cf 2016_2_summary
-    elif grt=='HEG':
-        V=0.65*c        #  set to 65% of RR calculation (no longer 80%) => cf 2016_2_summary
-
-    try:
-        slit_position = read_dict(FileName='Dict_Slit.txt')
-    except KeyError:
-        print_warning_message("Unable to read dictionary")
-        return
-
-    V2_center= slit_position[grt]['S2V']
-    H2_center= slit_position[grt]['S2H']
-    V1_center= slit_position[grt]['S1V']
-    H1_center= slit_position[grt]['S1H']
-
-    Size1A=( aperture_fit(hv,1)[0]*c_1A,       aperture_fit(hv,1)[1]*c_1A )
-    Size2B=( aperture_fit(hv,2)[0]*c_2B, round(aperture_fit(hv,2)[1]*c_2B*V,3))
-    slit1A_set(Size1A[0],Size1A[1],H1_center,V1_center,verbose)    # standard operating
-    slit1A_set(Size2B[0],Size2B[1],H2_center,V2_center,verbose)
-
diff --git a/iexcode/instruments/utilities.py b/iexcode/instruments/utilities.py
index 3e4b739171c309dee52bff4b64bcfba7f6fedf8d..e680a30cde984132f0ffdab4d8d311dff3e9397a 100644
--- a/iexcode/instruments/utilities.py
+++ b/iexcode/instruments/utilities.py
@@ -211,3 +211,4 @@ def AbortScript():
         return foo
     except KeyboardInterrupt as e:
         raise e
+
diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py
index 237efd84adb4548454acceb039dfb04b2889a60f..ff15f4d626828e3a054e7d5b99b3a18991e1afeb 100644
--- a/iexcode/instruments/xrays.py
+++ b/iexcode/instruments/xrays.py
@@ -13,12 +13,12 @@ from iexcode.instruments.IEX_VPU import *
 from iexcode.instruments.VLS_PGM import *
 from iexcode.instruments.slits import *
 from iexcode.instruments.shutters import *
-from iexcode.instruments.gate_valves import *
+from iexcode.instruments.valves import *
 from iexcode.instruments.diagnostics import *
-from iexcode.instruments.m3r import *
+from iexcode.instruments.m3r import m3r_align
 from iexcode.instruments.cameras import _enable_endstation_cameras
 from iexcode.instruments.utilities import print_warning_message,make_table
-from iexcode.instruments.current_amplifiers import ca_average
+from iexcode.instruments.current_amplifiers import ca_average, ca_detector_list
 from iexcode.instruments.Logfile import log_update
 
 mpa = iex.mpa
@@ -206,7 +206,7 @@ def energy_get_all(verbose=True):
     """
     d = ID_get_all(verbose=False)
     d.update(mono_get_all(verbose=False))
-    keylist = ['ID_Mode', 'ID_QP_ratio', 'ID_SP', 'ID_RBV','hv','grating']
+    keylist = ['ID_mode', 'ID_QP_ratio', 'ID_sp', 'ID_rbv','hv','grating']
     values = []
     for key in keylist:
         values.append(d[key])
@@ -216,6 +216,9 @@ def energy_get_all(verbose=True):
     return tuple(values)
     
 def energy_get():
+    """
+    return the mono energy readback
+    """
     hv = getE()
     return hv
 
@@ -230,31 +233,19 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True):
     m3r => if True optimizes the mirror for the d-branch only
     Previously: Set_BL, energy
     """
-    if iex.BL.xrays:
-        if hv_eV != _energy_range_check(hv_eV):
-            message_string = 'request photon energy '+str(hv_eV)+' not with the allowed range'
-            message_string = '\n closest allowed energy is '+str(_energy_range_check(hv_eV))
-            print_warning_message(message_string)
-
-
-        ID_energy_set(hv_eV,verbose=verbose)
-        mono_energy_set(hv_eV,verbose=verbose)
-        slits_set_BL(c_2B=slit_coeff,c_1A=1,verbose=verbose)
-
-        if m3r == True:
-            if iex.BL.branch() == 'd':
-                print('\nalign_m3r()')
-                try:
-                    m3r_align()
-                    sleep(1)
-                    if m3r_RY_pos_sp_get() == m3r_RY_pos_sp():
-                        m3r_align()
-                except:
-                    print('Unable to align; check camera settings.')
-    else:
-        message_string = 'iex.BL.xrays = False, energy is not set'
+    if hv_eV != _energy_range_check(hv_eV):
+        message_string = 'request photon energy '+str(hv_eV)+' not with the allowed range'
+        message_string = '\n closest allowed energy is '+str(_energy_range_check(hv_eV))
         print_warning_message(message_string)
 
+
+    ID_energy_set(hv_eV,verbose=verbose)
+    mono_energy_set(hv_eV,verbose=verbose)
+    apertures_set(c_2B=slit_coeff,c_1A=1,verbose=verbose)
+
+    if m3r == True:
+        m3r_align()
+
 def _energy_range_min_max():
     """
     returns the min,max energies for the current grating/ID setting
@@ -277,6 +268,51 @@ def _energy_range_check(hv):
     hv = np.max(hv_min,hv)
     return hv
 
+##############################################################################################################
+################################             beamline slits  = apertures          ##############################
+############################################################################################################## 
+
+def apertures_set(c_2B=1,c_1A=1,verbose=True):
+    """
+    Sets slit-1A and slit-2B for the current 
+    grating and photon energy to remove the heat bump
+
+    c_1A and c_2B are used to take a different ratio of the beam 
+    (1 = normal ops, < 1 to reduce flux)
+
+    Previously: SetSlit_BL
+    """
+    mono_vals=mono_get_all()
+    hv_rbv = mono_vals['ENERGY_MON']
+    grt  = mono_vals['GRT']
+    
+    # slit were defined for the range: 500 - 2000
+    hv = max(hv_rbv,500)
+    hv = min(hv_rbv,2000)
+    c = 4.2/2.2 # to account for the magnification difference between gratings
+
+    if grt == 'MEG':
+        V=0.65        #  set to 65% of RR calculation for both grt => cf 2016_2_summary
+    elif grt=='HEG':
+        V=0.65*c        #  set to 65% of RR calculation (no longer 80%) => cf 2016_2_summary
+
+    try:
+        slit_position = read_dict(FileName='Dict_Slit.txt')
+    except KeyError:
+        print_warning_message("Unable to read dictionary")
+        return
+
+    V2_center= slit_position[grt]['S2V']
+    H2_center= slit_position[grt]['S2H']
+    V1_center= slit_position[grt]['S1V']
+    H1_center= slit_position[grt]['S1H']
+
+    Size1A=( aperture_fit(hv,1)[0]*c_1A,       aperture_fit(hv,1)[1]*c_1A )
+    Size2B=( aperture_fit(hv,2)[0]*c_2B, round(aperture_fit(hv,2)[1]*c_2B*V,3))
+    slit1A_set(Size1A[0],Size1A[1],H1_center,V1_center,verbose)    # standard operating
+    slit1A_set(Size2B[0],Size2B[1],H2_center,V2_center,verbose)
+
+
 def mvID(val):
     """
     Sets the ID absolute set point (not optimized , mono & apertures stay fixed).
@@ -331,7 +367,7 @@ def grating(grating):
         main_shutter_close()
         print("Switching grating, please wait...")
         mono_grating_translate(grating,quiet=True)
-        slits_set_BL()
+        apertures_set()
 
         if shutter_open:
             main_shutter_open()
@@ -340,6 +376,13 @@ def grating(grating):
     else: 
         print("grating: "+grating)
 
+def grating_get():
+    """
+    returns the current grating
+    """
+    grt = mono_grating_get()
+    return grt
+
 def polarization(ID_mode):
     """
     Change beam polarization: ID_mode = 'H', 'V', 'RCP' or 'LCP'
@@ -357,8 +400,7 @@ def scanmono(start,stop,step,average_pnts=1,**kwargs):
     scans the mono at the current ID value
 
     """
-    #global BL
-    ca_average(average_pnts)
+    ca_average(average_pnts,ca_detector_list(iex.BL.branch))
 
     mono_scan_fillin(iex.BL.mda,start,stop,step,**kwargs)
 
@@ -369,10 +411,13 @@ def scanmono(start,stop,step,average_pnts=1,**kwargs):
 
 
 
-def scanXAS(ID_eV,start_stop_step_lists,**kwargs):
+def scanXAS(start_stop_step_lists,ID_eV=None, **kwargs):
     """
-    Sets the beamline to ID_eV and then scans the mono for XAS scans
-
+    scans the beamline energy:
+        ID_eV = None        => the ID stays at the current value (default) 
+        ID_eV = value       => set the ID 
+        ID_track = True     => ID will follow with the mono (SLOW but required in ARPES)
+      
     start_stop_step_lists is a list of lists for the different scan ranges
         start_stop_step_lists = [[start1,stop1,step1], [start1,stop1,step1],...]
         Note duplicates are removed and the resulting array is sorted in ascending order
@@ -396,17 +441,23 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs):
 
     scan_dim=kwargs['scan_dim']
     
-    #Setting up the ScanRecord for Mono in Table mode
-    hv_array = make_table(start_stop_step_lists)
-    mono_scan_fillin_table(iex.BL.mda,scan_dim,hv_array,**kwargs)
+    #Setting up the ScanRecord for Mono and ID in Table mode
+    mono_array,ID_array = BL_energy_tables(start_stop_step_lists)
+    kwargs.update('positioner_num',1)
+    mono_scan_fillin_table(iex.BL.mda,scan_dim,mono_array,**kwargs)
+    if ID_tracking == True:
+        kwargs.update('positioner_num',2)
+        ID_scan_fillin_table(iex.BL.mda,scan_dim,ID_array,**kwargs)
+        energy(ID_array[0],m3r=kwargs["m3r"])
+    elif ID_eV != None:
+        #Setting the beamline energy
+        energy(ID_eV,m3r=kwargs["m3r"])
 
     #Averaging and Normalization
-    ca_average(kwargs['average_pnts'])
+    ca_average(kwargs['average_pnts'],ca_detector_list(iex.BL.branch))
     if iex.BL.branch=="d":
         meshD("In")
-     
-    #Setting the beamline energy
-    energy(ID_eV,m3r=kwargs["m3r"])
+        print_warning_message('MeshD is not automatically removed')
 
     #mpa
     if iex.BL.endstation == "Kappa" and kwargs["mcp"]:
@@ -415,82 +466,18 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs):
     #Scanning
     if kwargs['execute']:
         mono_energy_set(hv_array[0])
-        BL.mda.go(scan_dim)
+        iex.BL.mda.go(scan_dim)
     
         #Setting everything back
         mono_energy_set(ID_eV)
-        mono_scan_after(BL.mda,scan_dim)
-        BL.mda.table_reset_after(scan_dim)
+        mono_scan_after(iex.BL.mda,scan_dim)
+        iex.BL.mda.table_reset_after(scan_dim)
 
-        if BL.endstation == "Kappa": 
+        if iex.BL.endstation == "Kappa": 
             if kwargs["mcp"]: 
                 mpa.HV_off()
-            print("WARNING: Mesh"+BL.branch+" is still In")        
-
-def scanXAS_BL(start_stop_step_lists,**kwargs):
-    """
-    scans the mono and the ID for XAS scans
-        Note: this is slow, but required in if the c-branch
-
-    start_stop_step_lists is a list of lists for the different scan ranges
-        start_stop_step_lists = [[start1,stop1,step1], [start1,stop1,step1],...]
-        Note duplicates are removed and the resulting array is sorted in ascending order
-
-    **kwargs:
-        scan_dim = 1 (default)
-        average_pnts: if using Keithlys this set the averaging; None for no averaging
-        m3r: if True the mirror is optimized before the start of the scan
-        mcp
-        execute: True/False to start the scan => True (default)
-    
-    Normalization:
-        - If in the D-branch the Mesh is put in but is not removed
-        - If in the C-branch we use the slit blades for normalization (ca13)
-    """
-    kwargs.setdefault("scan_dim",1)
-    kwargs.setdefault("average_pnts",1)
-    kwargs.setdefault("m3r",True)
-    kwargs.setdefault("mcp",True)    
-    kwargs.setdefault('execute',True)
-
-    scan_dim=kwargs['scan_dim']
-        
-    #Setting up the ScanRecord for Mono and ID in Table mode
-    mono_array,ID_array = BL_energy_tables(start_stop_step_lists)
-
-    kwargs.update('positioner_num',1)
-    mono_scan_fillin_table(BL.mda,scan_dim,mono_array,**kwargs)
-
-    kwargs.update('positioner_num',2)
-    ID_scan_fillin_table(BL.mda,scan_dim,ID_array,**kwargs)
-    
-    #Averaging and Normalization
-    ca_average(kwargs['average_pnts'])
-    if BL.branch=="d":
-        meshD("In")
-     
-    #Setting the beamline energy
-    slits_set_BL(mono_array[0],m3r=kwargs["m3r"])
-
-    #mpa
-    if BL.endstation == "Kappa" and kwargs["mcp"]:
-        mpa.HV_on()
-        
-    #Scanning
-    if kwargs['execute']:
-        mono_energy_set(mono_array[0])
-        ID_SP_set(ID_array[0])
-        BL.mda.go(scan_dim)
-
-        #Setting everything back
-        mono_energy_set(mono_array[0])
-        mono_scan_after(BL.mda,scan_dim)
-        BL.mda.table_reset_after(scan_dim)
+            print("WARNING: Mesh"+iex.BL.branch+" is still In")        
 
-        if BL.endstation == "Kappa": 
-            if kwargs["mcp"]: 
-                mpa.HV_off()
-            print("WARNING: Mesh"+BL.branch+" is still In")  
 
 def BL_energy_tables(start_stop_step_lists):
     """
@@ -510,50 +497,43 @@ def BL_energy_tables(start_stop_step_lists):
 
 
 ##############################################################################################################
-###########################               branch shutter, valves, safe_state                    ######################
+###########################               shutter check                 ######################
 ##############################################################################################################
-def get_branch(verbose=True):
-    """
-    gets the branch based on the position of m3r
-    """
-    branch = m3r_branch(verbose)
-    return branch
-
 
-def open_branch(branch=None,valve=False):
+def shutter_check(verbose=True):
     """
-        Opens the branch shutter, if branch is none, then uses the position of m3r to determine branch
+        Opens the shutter in the branch determined from the position of m3r
         
         Previously: Check_BranchShutter
     """
-    branch = get_branch(verbose=False)
-    
+    #main shutter
+    if main_shutter_status:
+        if verbose:
+            print("Main shutter already open")
+    else:
+        main_shutter_open()
+
+    #branch shutter
+    branch = m3r_branch(verbose)
     if branch_shutter_status(branch):
-        print(dateandtime(), +branch+" shutter already open..." ,)
+        if verbose:
+            print(dateandtime(), +branch+" shutter already open..." ,)
     else:
         while True:
             if branch_shutter_status(branch) == False :
-                print(dateandtime(), "Opening "+branch+" shutter ..." ,)
+                if verbose:
+                    print(dateandtime(), "Opening "+branch+" shutter ..." ,)
                 branch_shutter_open(branch,verbose=False)
                 sleep(30)
             else:
                 print(dateandtime(), +branch+" shutter is now open..." ,)
                 break
-    if valve:
-        GVs = branch_valves()
-        for GV in GVs:
-            valve_open(GV)
 
-def close_shutter(branch=None):
-    """
-        Closes the branch shutter, if branch is none, then uses the position of m3r to determine branch
-        
-        Previously: Close_CShutter,Close_DShutter
-    """
-    if branch is None:
-        branch = get_branch()
-    caput("PC:29ID:S"+branch+"S_CLOSE_REQUEST.VAL",1,wait=True,timeout=18000)
-    print("Closing "+branch+"-Shutter...")
+
+##############################################################################################################
+###########################               switch branch                 ######################
+##############################################################################################################
+
 
 def switch_branch(branch, force=False, shutter=True,scan_reset=True,enable_cams=True):
     """Switch beam into which = \"c\" or \"d\" branch (by retracting/inserting deflecting mirror)
@@ -592,10 +572,10 @@ def switch_branch(branch, force=False, shutter=True,scan_reset=True,enable_cams=
 
         # Open branch shutters:
             if shutter:
-                open_branch(branch,valve=False)
+                branch_shutter_open(branch,valve=False)
 
             if scan_reset:
-                BL.mda.reset()
+                iex.BL.mda.reset()
 
             if enable_cams:
                 _enable_endstation_cameras(branch)
@@ -617,13 +597,12 @@ def get_mirrors():
 ##############################################################################################################
 def slit(size):
     """
-    sets the exit slit based on BL.endstation
+    sets the exit slit based on iex.BL.endstation
 
         ARPES = 0 < x < 300  um
         Kappa  = 0 < x < 1000 um
     """
-    global BL
-    branch = BL.branch
+    branch = iex.BL.branch
     if branch == "c":
         slit3C_set(size, quiet=False)
     elif branch == "d":
@@ -632,13 +611,12 @@ def slit(size):
 
 def slit_get(verbose=True):
     """
-    sets the exit slit based on BL.endstation
+    sets the exit slit based on iex.BL.endstation
 
         ARPES = 0 < x < 300  um
         Kappa  = 0 < x < 1000 um
     """
-    global BL
-    branch = BL.branch
+    branch = iex.BL.branch
     if branch == "c":
         slit_size = slit3C_get(verbose=False)
         slit_center = np.nan
@@ -646,8 +624,8 @@ def slit_get(verbose=True):
         slit_size,slit_center = slit3D_get(verbose=False)
 
     if verbose:
-        message = BL.branch+' exit slit: '+str(slit_size)
-        message += ", @ "+str(slit_center) if BL.branch is not 'c' else ''
+        message = iex.BL.branch+' exit slit: '+str(slit_size)
+        message += ", @ "+str(slit_center) if iex.BL.branch is not 'c' else ''
         print(message)    
     return slit_size,slit_center
 
diff --git a/iexcode/launch_ARPES.py b/iexcode/launch_ARPES.py
index 798ca5c1be0a3021ce82a5cdaf0af8eedd60e623..5e42fdfbfaa88185a0b350c9091be2ef61ad2a0c 100644
--- a/iexcode/launch_ARPES.py
+++ b/iexcode/launch_ARPES.py
@@ -8,7 +8,7 @@ from epics import caget,caput,PV
 import iexcode.instruments.cfg as iex
 from iexcode.instruments.cameras import cam_snap
 from iexcode.instruments.utilities import playsound
-from iexcode.instruments.beamline import get_all
+from iexcode.instruments.get_all import get_all
 
 #xray stuff
 
diff --git a/iexcode/launch_xrays.py b/iexcode/launch_xrays.py
index ed42729f9b6aed1143e73352afd037b7d3ac6a4d..475d15cf2abba51b7a60c4b59cde46628bd17d49 100644
--- a/iexcode/launch_xrays.py
+++ b/iexcode/launch_xrays.py
@@ -1,7 +1,7 @@
-from iexcode.instruments.beamline import * 
+from iexcode.instruments.get_all import * 
 from iexcode.instruments.diagnostics import * 
 from iexcode.instruments.FMB_mirrors import * 
-from iexcode.instruments.gate_valves import * 
+from iexcode.instruments.valves import * 
 from iexcode.instruments.hxp_mirrors import * 
 from iexcode.instruments.IEX_VPU import * 
 from iexcode.instruments.m3r import * 
diff --git a/iexcode/macros/quick_plot.py b/iexcode/macros/quick_plot.py
index c4ca21637d4ca36a0b2bec68618036e5544fd27d..f4670aeb1001b40f445fd2511608c627945aef5a 100755
--- a/iexcode/macros/quick_plot.py
+++ b/iexcode/macros/quick_plot.py
@@ -35,7 +35,7 @@ try:
     from epics import caget
     from ..instruments.IEX_endstations import BL
     from ..instruments.utilities import read_dict,today
-    from ..instruments.slits import slits_set_BL
+    from ..instruments.slits import apertures_set
     from IEXcode.iexcode.current_amplifiers import current2flux
 except:
     print("EPICS package and dependent functions are not installed")
@@ -2385,7 +2385,7 @@ def update_slit_dict(**kwargs):
             f.write('\n')
             print('\nWriting dictionary to:',join(filepath, filename))
 
-        slits_set_BL()
+        apertures_set()
         return slit_position
 
 
diff --git a/iexcode/macros/start_of_the_week.py b/iexcode/macros/start_of_the_week.py
index 0cc64c50043cba4e301bde64afdefe5d857f9fcf..24ff756fe4bb352df7ca0fc5b8cc6379614669d8 100644
--- a/iexcode/macros/start_of_the_week.py
+++ b/iexcode/macros/start_of_the_week.py
@@ -232,7 +232,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
                 sleep(1)
                 scan_narrow_slit('1H',[0.25, -3, 3, 0.1])
                 sleep(1)
-                slits_set_BL()
+                apertures_set()
                 m=BL.mda.lastFileNum()
                 try:
                     V1=fit_mda(m-1,detDiode,1,'gauss');plt.show()
@@ -254,7 +254,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
             flag=True
             while flag:
                 mono_energy_set(500)
-                slits_set_BL()
+                apertures_set()
                 n=2 if 'extended_range' in kwargs  else 1
                 scan_mono_vs_slit('2V',[0.25*c,-2*c*n,2*c*n,0.5],[475,515,2],comment='Mono/Slit - 2V')    #10/20 min for MEG/HEG
                 scan_mono_vs_slit('2H',[0.25,-2*n,2*n,0.5],[475,515,2],comment='Mono/Slit - 2H')    #10min