diff --git a/TODO.org b/TODO.org
index 7c718ba74a02b89b70edea88fa540cc7d3cf8feb..bc11a5eab720ac8bc222ff1b99b6bc30ee65b5b9 100644
--- a/TODO.org
+++ b/TODO.org
@@ -150,7 +150,8 @@ That went very deep haha. alot of memory allocation stuff
 *** DONE Make new c function run_binary_with_custom_logging
     CLOSED: [2019-11-08 Fri 21:19]
 *** TODO Put in some new tests in the python test api
-*** TODO Make sure the sharedlibs get written to the correct directory
+*** DONE Make sure the sharedlibs get written to the correct directory
+    CLOSED: [2019-11-10 Sun 00:21]
 ** General:
 *** DONE Get a more reliable way of loading the default values (running a ./tbse echo or something?)
     CLOSED: [2019-10-29 Tue 17:44]
diff --git a/binaryc_python_utils/custom_logging_functions.py b/binaryc_python_utils/custom_logging_functions.py
index bfd3c2f9843da1a2f754af583b4cfeb1e13f5f70..5e95463b7ac5365828570a67bf70aa9556c40a7a 100644
--- a/binaryc_python_utils/custom_logging_functions.py
+++ b/binaryc_python_utils/custom_logging_functions.py
@@ -2,6 +2,7 @@ import os
 import textwrap
 import subprocess
 import socket
+import tempfile
 
 # Functions for the automatic logging of stuff
 def autogen_C_logging_code(logging_dict):
@@ -228,4 +229,20 @@ def compile_shared_lib(code, sourcefile_name, outfile_name):
         shell=True)
 
     if res:
-        print('Output of compilation command:\n{}'.format(res))
\ No newline at end of file
+        print('Output of compilation command:\n{}'.format(res))
+
+
+def temp_custom_logging_dir():
+    """
+    Function to return the path the custom logging library shared object and script will be written to.
+
+    Makes use of os.makedirs exist_ok which requires python 3.2+
+    """
+
+    tmp_dir = tempfile.gettempdir()
+    path = os.path.join(tmp_dir, 'binary_c_python')
+
+    # 
+    os.makedirs(path, exist_ok=True)
+
+    return path
\ No newline at end of file
diff --git a/custom_logging.c b/custom_logging.c
deleted file mode 100644
index 57b6574fa570ef4b5980aabc274710a1e6efeda5..0000000000000000000000000000000000000000
--- a/custom_logging.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma push_macro("MAX")
-#pragma push_macro("MIN")
-#undef MAX
-#undef MIN
-#include "binary_c.h"
-
-// add visibility __attribute__ ((visibility ("default"))) to it 
-void binary_c_API_function custom_output_function(struct stardata_t * stardata);
-void binary_c_API_function custom_output_function(struct stardata_t * stardata)
-{
-    // struct stardata_t * stardata = (struct stardata_t *)x;
-    Printf("MY_STELLAR_DATA %g %g\n",((double)stardata->model.time),((double)stardata->star[0].mass));
-Printf("my_sss2 %g %g\n",((double)stardata->model.time),((double)stardata->star[1].mass));;
-}
-
-#undef MAX 
-#undef MIN
-#pragma pop_macro("MIN")
-#pragma pop_macro("MAX")    
\ No newline at end of file
diff --git a/testing_examples/run_system_with_custom_logging.py b/testing_examples/run_system_with_custom_logging.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/tests_and_snippets/testing.py b/tests_and_snippets/custom_logging_examples.py
similarity index 69%
rename from tests_and_snippets/testing.py
rename to tests_and_snippets/custom_logging_examples.py
index 418e4486a9a25490f8bfee2924b3763f612c3b8d..5bd5b9ea4cedf55e73cbbc1a47aa1eb19bf728c7 100644
--- a/tests_and_snippets/testing.py
+++ b/tests_and_snippets/custom_logging_examples.py
@@ -1,6 +1,8 @@
 import ctypes
+import tempfile
+import os
 
-from binaryc_python_utils.custom_logging_functions import autogen_C_logging_code, binary_c_log_code, compile_shared_lib
+from binaryc_python_utils.custom_logging_functions import autogen_C_logging_code, binary_c_log_code, compile_shared_lib, temp_custom_logging_dir
 import binary_c
 
 # generate logging lines
@@ -12,20 +14,25 @@ logging_line = autogen_C_logging_code(
 )
 
 # Generate code around logging lines
-created_code = binary_c_log_code(logging_line)
+custom_logging_code = binary_c_log_code(logging_line)
 
 # 
-compile_shared_lib(created_code, sourcefile_name='custom_logging.c', outfile_name='libcustom_logging.so')
+compile_shared_lib(created_code, 
+        sourcefile_name=os.path.join(temp_custom_logging_dir(), 'custom_logging.c'), 
+        outfile_name=os.path.join(temp_custom_logging_dir(), 'libcustom_logging.so')
+    )
 
 # Loading library
 dll1 = ctypes.CDLL('libgslcblas.so', mode=ctypes.RTLD_GLOBAL)
 dll2 = ctypes.CDLL('libgsl.so', mode=ctypes.RTLD_GLOBAL)
 dll3 = ctypes.CDLL('libbinary_c.so', mode=ctypes.RTLD_GLOBAL)
-libmean = ctypes.CDLL("libcustom_logging.so", mode=1) # loads the shared library
+libmean = ctypes.CDLL(os.path.join(temp_custom_logging_dir(), 'libcustom_logging.so'),
+    mode=ctypes.RTLD_GLOBAL) # loads the shared library
 
 # Get memory adress of function. mimicking a pointer
 mem = ctypes.cast(libmean.custom_output_function, ctypes.c_void_p).value
 
+# 
 m1 = 15.0 # Msun
 m2 = 14.0 # Msun
 separation = 0 # 0 = ignored, use period
@@ -38,7 +45,5 @@ argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g}
     
 output = binary_c.run_binary_custom_logging(argstring, mem)
 # output = binary_c.run_binary(argstring)
-
-# print ("\n\nBinary_c output:\n\n")
 print (output)
 
diff --git a/tests_and_snippets/test b/tests_and_snippets/test.py
similarity index 100%
rename from tests_and_snippets/test
rename to tests_and_snippets/test.py