diff --git a/config.py b/config.py
index 506d0ab904bf05cfabfa30f1609d848a24f28e04..0eaa612e7b10a951d4e6f0949c1e2ba6a5a34f6f 100644
--- a/config.py
+++ b/config.py
@@ -52,7 +52,7 @@ _device_type = 'SQM_LE' # Device type in the Header
 _device_id = _device_type + '-' + _observatory_name # Long Device lame
 _device_locationname = 'Pino Torinese/Italy - Astrophysical Observatory of Torino' # Device location in the world
 _data_supplier = 'Dario Barghini / INAF - OATo' # Data supplier (contact)
-_device_addr = '169.254.156.64' # Default IP address of the ethernet device (if not automatically found)
+_device_addr = '169.254.65.200' # Default IP address of the ethernet device (if not automatically found)
 
 '''
 ----------------
@@ -86,7 +86,7 @@ _mysql_port = None # Port of the MySQL server
 DIRECTORY settings
 ------------------
 '''
-main_directory = "C:\\sqm\\pysqm_data" # Main directory
+main_directory = "C:\\pysqm\\data" # Main directory
 monthly_data_directory = main_directory + "\\monthly\\" # Monthly (permanent) data
 daily_data_directory = main_directory + "\\daily\\" # Daily (permanent) data
 daily_graph_directory = main_directory + "\\daily\\" # Daily (permanent) graph
diff --git a/pysqm/__main__.py b/pysqm/__main__.py
index f13c77f705d8e733cb3162831c89c9fdcf561efb..8b5c4bb25d866d6ff989a8b98a84d9b216d8ccc1 100644
--- a/pysqm/__main__.py
+++ b/pysqm/__main__.py
@@ -27,16 +27,20 @@ ____________________________
 #import sys
 
 #import pysqm.main as main
-from pysqm import main
-
-while 1==1:
-    # Loop forever to make sure the program does not die.
-    try:
-        main.loop()
-    except Exception as e:
-        print('')
-        print('FATAL ERROR while running the main loop !!')
-        print('Error was:')
-        print(e)
-        print('Trying to restart')
-        print('')
+from pysqm import main as pysqm_main
+
+def main():
+    while 1==1:
+        # Loop forever to make sure the program does not die.
+        try:
+            pysqm_main.loop()
+        except Exception as e:
+            print('')
+            print('FATAL ERROR while running the main loop !!')
+            print('Error was:')
+            print(e)
+            print('Trying to restart')
+            print('')
+
+if __name__ == "__main__":
+    main()
\ No newline at end of file
diff --git a/pysqm/main.py b/pysqm/main.py
index be7d9c86f168be4ff9e6f6282a3e0360e934d2a1..2a78059c6ed78f9a348dafc31dc31c9ddf265cd2 100644
--- a/pysqm/main.py
+++ b/pysqm/main.py
@@ -81,7 +81,6 @@ for directory in [config.monthly_data_directory,config.daily_data_directory,conf
     if not os.path.exists(directory):
         os.makedirs(directory)
 
-
 '''
 Select the device to be used based on user input
 and start the measures
@@ -107,6 +106,7 @@ def loop():
     observ = define_ephem_observatory()
     niter = 0
     old_daily_datafile = ''
+    old_yearmonth = ''
     DaytimePrint = True
     print('Starting readings ...')
     while 1<2:
@@ -132,6 +132,12 @@ def loop():
             else:
                 old_daily_datafile = mydevice.daily_datafile
                 niter = 0
+
+            # Create new month directory in daily_data_directory
+            if mydevice.yearmonth != old_yearmonth:
+                directory = config.daily_data_directory+'/'+mydevice.yearmonth
+                if not os.path.exists(directory):
+                    os.makedirs(directory)
             
             ''' Get values from the photometer '''
             try:
diff --git a/pysqm/plot.py b/pysqm/plot.py
index c9a78f2da0f8e29d4a081cef389b3b84a98b2092..2651539bb6ab3193cfef775fb578e303ffba5979 100644
--- a/pysqm/plot.py
+++ b/pysqm/plot.py
@@ -604,11 +604,11 @@ class Plot(object):
          color='#2ca02c',fontsize='small',transform = self.thegraph_sunalt.transAxes)
         self.thegraph_sunalt.text(0.75,0.84,'AM: '+aftermidnight_label,\
          color='#1f77b4',fontsize='small',transform = self.thegraph_sunalt.transAxes)
-
+        
         '''
         if np.size(Data.Night)==1:
             self.thegraph_sunalt.text(0.75,1.015,'Moon: %d%s (%d%s)' \
-             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,"$^\mathbf{o}$"),\
+             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,r"$^\mathbf{o}$"),\
              color='#d62728',fontsize='small',fontname='monospace',\
              transform = self.thegraph_sunalt.transAxes)
         '''
@@ -683,7 +683,7 @@ class Plot(object):
 
         if np.size(Data.Night)==1:
             self.thegraph_time.text(0.75,1.015,'Moon: %d%s (%d%s)' \
-             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,"$^\mathbf{o}$"),\
+             %(Ephem.moon_phase, "%", Ephem.moon_maxelev*180./np.pi,r"$^\mathbf{o}$"),\
              color='black',fontsize='small',fontname='monospace',\
              transform = self.thegraph_time.transAxes)
 
@@ -830,9 +830,9 @@ def make_plot(input_filename=None,send_emails=False,write_stats=False):
     output_filenames = [\
         str("%s/%s_%s.png" %(config.current_data_directory,\
             config._device_shorttype,config._observatory_name)),\
-        str("%s/%s_120000_%s-%s.png" \
-            %(config.daily_graph_directory, str(NSBData.Night).replace('-',''),\
-              config._device_shorttype, config._observatory_name))\
+        str("%s/%s_120000_%s-%s.png"\
+            %(config.daily_graph_directory+str(NSBData.Night)[0:7].replace('-',''),\
+              str(NSBData.Night).replace('-',''),config._device_shorttype, config._observatory_name))\
     ]
 
     for output_filename in output_filenames:
diff --git a/pysqm/read.py b/pysqm/read.py
index b1973f7b5be8370bc886cb7072d3f5e973e6a26f..e15c4b5daa4c539411d630f0a988a19e2d3a6fd2 100644
--- a/pysqm/read.py
+++ b/pysqm/read.py
@@ -184,8 +184,10 @@ class device(observatory):
         date_time_file = self.local_datetime(\
          self.read_datetime())-datetime.timedelta(hours=12)
         date_file = date_time_file.date()
-        yearmonth = str(date_file)[0:7]
-        yearmonthday = str(date_file)[0:10]
+        yearmonth = str(date_file)[0:7].replace('-','')
+        yearmonthday = str(date_file)[0:10].replace('-','')
+        self.yearmonth = yearmonth
+        self.yearmonthday = yearmonthday
 
         self.monthly_datafile = \
          config.monthly_data_directory+"/"+config._device_shorttype+\
@@ -194,7 +196,7 @@ class device(observatory):
         # config.daily_data_directory+"/"+config._device_shorttype+\
         # "_"+config._observatory_name+"_"+yearmonthday+".dat"
         self.daily_datafile = \
-         config.daily_data_directory+"/"+\
+         config.daily_data_directory+"/"+yearmonth+"/"+\
          yearmonthday.replace('-','')+'_120000_'+\
          config._device_shorttype+'-'+config._observatory_name+'.dat'
         self.current_datafile = \
diff --git a/setup.py b/setup.py
index ba769d2fca2120ef928f106eb83c0d6aec812da4..bab2b163e96d9c65abe83295a1039a152c3c4c52 100644
--- a/setup.py
+++ b/setup.py
@@ -3,10 +3,10 @@
 from distutils.core import setup
 
 setup(name='pysqm',
-      version='3.1',
-      maintainer='Thorsten Alteholz',
-      maintainer_email='python@alteholz.de',
-      url='https://github.com/alteholz/PySQM',
+      version='4',
+      maintainer='Dario Barghini',
+      maintainer_email='dario.barghini@inaf.it',
+      url='https://www.ict.inaf.it/gitlab/dario.barghini/pysqm_darkersky4ce.git',
       license='GPLv3',
       description='SQM reading and plotting software',
       packages=['pysqm'],
@@ -23,5 +23,6 @@ setup(name='pysqm',
                    "Operating System :: OS Independent",
                    "Topic :: Scientific/Engineering :: Astronomy",
                    ],
-      long_description=open('README.txt', encoding="utf-8").read()
+      long_description=open('README.md', encoding="utf-8").read(),
+      entry_points={"console_scripts": ["pysqm=pysqm.__main__:main"]}
       )