diff --git a/app/experiment/templates/experiment_statistics.html b/app/experiment/templates/experiment_statistics.html
index d3a8aaec93cb7a1199ab22b7cdb71c57086b876c..084feb968d2a18b5347cb4affa123aec9f72c9e8 100644
--- a/app/experiment/templates/experiment_statistics.html
+++ b/app/experiment/templates/experiment_statistics.html
@@ -219,8 +219,9 @@
 
 <!-- <script type=module src="{{ url_for('static', filename='lib/js/socket.io.esm.min.js') }}"></script> -->
 <script src="{{ url_for('static', filename='lib/js/socket.io.min.js') }}"></script>
+<script src="{{ url_for('static', filename='lib/js/socket.io.min.js.map') }}"></script>
 <script src="{{ url_for('static', filename='js/urls.js') }}"></script>
 <script type=module src="{{ url_for('static', filename='js/getDrawing.js') }}"></script>
 <script src="{{ url_for('static', filename='js/getCSV.js') }}"></script>
 
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/app/experiment/views.py b/app/experiment/views.py
index 05350fb0bb1a5dd166b2489e39cd5e3f5bf070fd..4df2d0bbfb2459b56c8765d51557cdb158cdb834 100644
--- a/app/experiment/views.py
+++ b/app/experiment/views.py
@@ -206,8 +206,14 @@ def remove():
                 db.session.commit()
 
                 # Remove empty directories
-                os.rmdir(APP_ROOT + '/static/embody_images/' + str(exp_id))
-                os.rmdir(APP_ROOT + '/static/experiment_stimuli/' + str(exp_id))
+                try:
+                    os.rmdir(APP_ROOT + '/static/embody_images/' + str(exp_id))
+                except FileNotFoundError as err:
+                    app.logger.info(err)
+                try:
+                    os.rmdir(APP_ROOT + '/static/experiment_stimuli/' + str(exp_id))
+                except FileNotFoundError as err:
+                    app.logger.info(err)
 
                 flash("Experiment was removed from database!")
                 return redirect(url_for('index'))
@@ -1023,7 +1029,7 @@ def download_csv():
         return send_file(path,
                          mimetype='text/csv',
                          as_attachment=True,
-                         attachment_filename=filename)
+                         download_name=filename)
 
     finally:
         os.remove(path)
@@ -1061,11 +1067,13 @@ def download_csv(meta):
 
     # create temporary file
     fd, path = mkstemp()
+
     with os.fdopen(fd, 'w', buffering=1) as tmp:
         if generate_csv(exp_id, tmp):
             # return path and filename to front so user can start downloading
             filename = "experiment_{}_{}".format(
                 exp_id, date.today().strftime("%Y-%m-%d"))
+
             path = path.split('/')[-1]
             emit('file_ready', {'path': path, 'filename': filename})
         else:
diff --git a/app/static/js/getCSV.js b/app/static/js/getCSV.js
index 4b0313bbc2f96e59041548022644136f886ac246..33762b0e4d0724567acfda55e041f80164b959d6 100644
--- a/app/static/js/getCSV.js
+++ b/app/static/js/getCSV.js
@@ -40,7 +40,6 @@ $(document).ready(function()  {
         });
 
         socket.on('file_ready', function(file) {
-
             socket.emit('end')
             socket.disconnect()            
 
@@ -59,6 +58,10 @@ $(document).ready(function()  {
             progressBarContainer.addClass("hidden")
             progressBar.width('0%')
         });
+
+	    socket.on("connect_error", (err) => {
+		      console.log(`connect_error due to ${err.message}`);
+	    });
     }
 
 
@@ -66,7 +69,7 @@ $(document).ready(function()  {
         event.preventDefault()
 
         // Init socket
-        var socket = io.connect(exportURL);
+        const socket = io(exportURL);
         initConnection(socket)
 
         // start generating csv file...
diff --git a/app/static/js/urls.js b/app/static/js/urls.js
index 86a9b1e032071bcbfdaf7aaf2bbc4fb2baa0b174..bc2e22371dd52ac2f969251e8a59d9f244a335cf 100644
--- a/app/static/js/urls.js
+++ b/app/static/js/urls.js
@@ -1,5 +1,5 @@
-const baseURI = "localhost:8000/";
-//const baseURI = 'http://onni.utu.fi/';
+//const baseURI = 'https://onni.utu.fi/';
+const baseURI = 'https://petrating-01.utu.fi/';
 
 var exportURL = baseURI + "download_csv";
 var getDrawingURI = baseURI + "create_embody";
diff --git a/app/utils.py b/app/utils.py
index 9fc8802751717657f9761625779ca9564de4cc8c..2c0043db54747deb60d5f8d5f704a78c627e8dbf 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -169,9 +169,9 @@ def generate_csv(exp_id, file_handle):
                 # to ensure that all internal buffers associated with fd are written to disk
                 file_handle.flush()
             except Exception as exc:
-                print('generated an exception: {}'.format(exc))
+                app.logger.info('generated an exception: {}'.format(exc))
                 # return False
-    
+
     return True
 
 
diff --git a/requirements.txt b/requirements.txt
index b2a1ee26080efff4cc929877db77cc01ac17009b..6f0d513fe493cf81ad11bfb93eca260775c00812 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,7 +12,7 @@ Flask-WTF==1.2.1
 gevent==23.9.1
 greenlet==3.0.1
 gunicorn==19.9.0
-matplotlib==3.0.3
+matplotlib==3.8.1
 networkx==2.2
 numpy==1.24.4
 Pillow