diff --git a/.gitignore b/.gitignore
index aa44b7c51bbae4d4d64eaa8d49b2ff6d443d0e82..dc9b51991e5a9ae1ac45108c80f4a1b27728c3de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
+make_output.txt
+*.org~
 *.so
 *.pyc
 build/*
 binary_c_python_api.o
 output/*
 *.nfs*
+*.swp
diff --git a/Makefile b/Makefile
index 4209c331c46c74e9138cd3d98fac5716963e0cac..a327be90036e3c2a25687a2d2d9a768079bc1dac 100644
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,12 @@ CC      := gcc
 LD      := gcc
 PROGRAM := binary_c_python_api
 MAKE    := /usr/bin/make
-LIBS 	:= -lbinary_c `$(BINARY_C)/binary_c-config --libs` 
+LIBS 	:= -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs)
+#`$(BINARY_C)/binary_c-config --libdirs_list` 
 C_SRC   := binary_c_python_api.c
 OBJECTS := $(C_SRC:.c=.o)
 OBJ_FLAGS := -c
-CFLAGS := -fPIC `$(BINARY_C)/binary_c-config --flags` -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API 
+CFLAGS := -fPIC $(shell $(BINARY_C)/binary_c-config --flags | sed s/-fvisibility=hidden// ) -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API 
 SO_FLAGS := -shared -o
 SO_NAME := libbinary_c_api.so
 
@@ -31,5 +32,3 @@ all: $(OBJECTS)
 
 clean:
 	rm -f *.o *.so
-	find build/ -type f -delete
-	rmdir build/*
diff --git a/README.md b/README.md
index 4684344406ace48a0e830f06dfeff7cf95545bc0..98ab80fe34b1093817757a896feb58e43dfbf38f 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 Based on a original work by Jeff Andrews (can be found in old_solution/ directory)
 updated and extended for Python3 by Robert Izzard, David hendriks
 
-**THIS CODE IS VERY EXPERIMENTAL AND PROBABLY WILL NOT WORK**
+Warning : THIS CODE IS EXPERIMENTAL!
 
 r.izzard@surrey.ac.uk
 http://personal.ph.surrey.ac.uk/~ri0005/binary_c.html
@@ -48,22 +48,3 @@ Usage notes
 When running a jupyter notebook and importing binary_c, it might happen that the module binary_c cannot be found. I experienced this when I executed Jupyter Notebook from a virtual environment which didnt use the same python (version/binary/shim) as the one I built this library with. Make sure jupyter does use the same underlying python version/binary/shim. That resolved the issue for me.
 
 Also: I figured that having binaryc output the log like "<LOG HEADER> t=10e4 ..." (i.e. printing the parameter names as well as their values) would be useful because in that way one can easily have python read that out automatically instead of having to manually copy the list of parameter names.
-
-
-
-TODO 
----------------------
-General:
-- ?Put the header and src files in a dedicated directory. 
-- ?Have the compiled files be written into build
-- Get a more reliable way of loading the default values (running a ./tbse echo or something?)
-- make routine that reads out all the lines, splits them into pieces and reads out the correct key
-- Add PYTHONPATH thing to readme
-- Make sure importing binary_c is not a problem
-
-If we're going to do populations:
-- Use sphinx for auto generation of docs
-- Use queueing system/asynchronous task queue
-- Make some parse-data that can be easily used
-- Make some simple script to assign probabilities
-- rebuild all perl stuff into a python grid code.
diff --git a/TODO.org b/TODO.org
new file mode 100644
index 0000000000000000000000000000000000000000..bc11a5eab720ac8bc222ff1b99b6bc30ee65b5b9
--- /dev/null
+++ b/TODO.org
@@ -0,0 +1,168 @@
+* Todo list for the binary_c-python
+** Logging functionality:
+*** Idea
+Idea is to be able to give a string via python that will be used in the through the libbinary_c.so so that log_every_timestep.c 
+The code below is the piece in log_every_timestep that uses it.
+
+    if(stardata->preferences->custom_output_function != NULL)
+    {
+        Dprint("calling custom output function %p\n",
+               stardata->preferences->custom_output_function);
+        stardata->preferences->custom_output_function(stardata);
+    }
+
+So the function should recieve 'stardata' as input.
+
+We can do that with providing a logging string alltogether, or generate a logging function
+
+In either way, this should be passed to stardata->preferences->custom_output_function as a pointer to that function
+
+*** Provide string for logging
+In perl this is done in the following way:
+**** code to input
+And then to use it via 
+    $population->set(
+        C_logging_code => '
+             PRINTF("MY_STELLAR_DATA %g %g %g %g\n",
+                 stardata->model.time,
+                 stardata->star[0].mass,
+                 stardata->model.probability,
+                 stardata->model.dt);
+                       '
+    );
+**** code to handle that input
+sub binary_c_log_code
+{
+    my ($code) = @_;
+    return "
+#pragma push_macro(\"MAX\")
+#pragma push_macro(\"MIN\")
+#undef MAX
+#undef MIN
+#include \"binary_c.h\"
+
+void custom_output_function(SV * x);
+SV * custom_output_function_pointer(void);
+
+SV * custom_output_function_pointer()
+{
+    /*
+     * use PTR2UV to convert the function pointer 
+     * &custom_output_function to an unsigned int,
+     * which is then converted to a Perl SV
+     */
+    return (SV*)newSVuv(PTR2UV(&custom_output_function));
+}
+
+void custom_output_function(SV * x)
+{
+    struct stardata_t * stardata = (struct stardata_t *)x;
+    $code;
+}
+#undef MAX 
+#undef MIN
+#pragma pop_macro(\"MIN\")
+#pragma pop_macro(\"MAX\")
+";
+}
+Or use it via:
+*** auto logging
+We should also try to be able to have the code autogenerate some logging function via the following:
+**** input in perl
+$population->set(    C_auto_logging => {
+        'MY_STELLAR_DATA' =>
+            [
+             'model.time',
+             'star[0].mass',
+             'model.probability',
+             'model.dt'
+            ]
+    });
+**** code to handle that input
+Which is handled in perl via (see binary_grid2.pm
+sub autogen_C_logging_code
+{
+    # given a hash of arrays of variable names, where the hash
+    # key is the header, autogenerate PRINTF statements
+    my ($self) = @_;
+    my $code = undef;
+    if(defined $self->{_grid_options}->{C_auto_logging} &&
+       ref $self->{_grid_options}->{C_auto_logging} eq 'HASH'
+        )
+    {
+        $code = '';
+
+        foreach my $header (keys %{$self->{_grid_options}->{C_auto_logging}})
+        {
+            if(ref $self->{_grid_options}->{C_auto_logging}->{$header} eq 'ARRAY')
+            {
+                $code .= 'PRINTF("'.$header.' ';
+                foreach my $x (@{$self->{_grid_options}->{C_auto_logging}->{$header}})
+                {
+                    $code .= '%g ';
+                }
+                $code .= '\n"';
+
+                foreach my $x (@{$self->{_grid_options}->{C_auto_logging}->{$header}})
+                {
+                    $code .= ',((double)stardata->'.$x.')';
+                }
+                $code .= ');'
+            }
+        }
+    }
+    print "MADE AUTO CODE \n\n************************************************************\n\n$code\n\n************************************************************\n";
+
+    return $code;
+}
+*** DONE Make function in python that puts code into c function
+    CLOSED: [2019-10-31 Thu 11:13]
+*** DONE Make function in python that generates c-function from a list of arguments
+    CLOSED: [2019-10-29 Tue 23:52]
+*** DONE Resolve current issue malloc
+    CLOSED: [2019-11-08 Fri 11:12]
+➜  binary_c-python git:(master) ✗ python python_API_test.py 
+Traceback (most recent call last):
+  File "python_API_test.py", line 3, in <module>
+    import binary_c
+ImportError: /home/david/projects/binary_c_root/binary_c-python/libbinary_c_api.so: undefined symbol: MALLOC
+
+I get this error when I am using the master version of binary_c with either branches of the python wrapper..
+
+That went very deep haha. alot of memory allocation stuff
+
+*** DONE Make sure this works with the last major release of binaryc
+    CLOSED: [2019-11-08 Fri 15:00]
+*** DONE Finish testing a simpler case (see other repo)
+    CLOSED: [2019-11-08 Fri 09:37]
+*** DONE Make master master work
+    CLOSED: [2019-11-08 Fri 15:00]
+*** DONE Sync master with david_branch
+    CLOSED: [2019-11-08 Fri 15:00]
+*** DONE make tag of old master branch for future reference
+    CLOSED: [2019-11-08 Fri 15:00]
+*** DONE Implement the autogeneration of the library
+    CLOSED: [2019-11-08 Fri 15:48]
+*** DONE Load all the things with the c-types
+    CLOSED: [2019-11-08 Fri 18:49]
+*** DONE Implement new function for run_binary_with_custom_logging
+    CLOSED: [2019-11-08 Fri 21:19]
+*** 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
+*** 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]
+*** DONE make routine that reads out all the lines, splits them into pieces and reads out the correct key
+    CLOSED: [2019-10-29 Tue 17:43]
+*** TODO Put header and other source files in a dedicated directory
+*** TODO Use sphinx or read the docs for auto generation of documentation
+*** TODO Have the compiled files put into a build directory
+*** TODO add pythonpath thing to readme
+*** TODO make script that will set up binaryc automatically so that this can become an out of the box thing
+*** TODO Test the importing of this code from different places
+** Population ideas
+*** TODO Queuing system and some multiprocessing to run many systems
+*** TODO Consider rewriting the work that perl does
diff --git a/binary_c_python.c b/binary_c_python.c
index 17d85dedd9462ae947a5b8997abeab4a2be8a541..b94452b2470b7144959a7da18561ddc5f7fd22a8 100644
--- a/binary_c_python.c
+++ b/binary_c_python.c
@@ -7,7 +7,7 @@
  * Remember: variables must be passed by references
  * (i.e. as pointers).
  *
- * See apitest.py for an expmple of how to use these functions.
+ * See apitest.py for an example of how to use these functions.
  *
  * See also
  * http://www-h.eng.cam.ac.uk/help/tpl/languages/mixinglanguages.html
@@ -22,7 +22,7 @@
  */
 /************************************************************/
 
-
+// Docstrings
 static char module_docstring[] MAYBE_UNUSED =
     "This module is a python wrapper around binary_c";
 #ifdef __DEPRECATED
@@ -33,6 +33,8 @@ static char run_binary_docstring[] =
     "Run one binary using binary_c";
 static char run_binary_with_logdocstring[] =
     "Run one binary using binary_c and allow the logfile to be written. Do not use for populations!";
+static char run_binary_custom_loggingdocstring[] =
+    "TODO";
 static char new_binary_system_docstring[] =
     "Return an object containing a binary, ready for evolution";
 static char function_prototype_docstring[] =
@@ -41,29 +43,35 @@ static char return_arglines_docstring[] =
     "Return the default args for a binary_c system";
 static struct libbinary_c_store_t *store = NULL;
 
+// Initialize pyobjects
 #ifdef __DEPRECATED
 static PyObject* binary_c_create_binary(PyObject *self, PyObject *args);
 #endif
 static PyObject* binary_c_run_binary(PyObject *self, PyObject *args);
-static PyObject* binary_c_run_binary_with_log(PyObject *self, PyObject *args);
+static PyObject* binary_c_run_binary_with_logfile(PyObject *self, PyObject *args);
+static PyObject* binary_c_run_binary_custom_logging(PyObject *self, PyObject *args);
 static PyObject* binary_c_function_prototype(PyObject *self, PyObject *args);
 static PyObject* binary_c_new_binary_system(PyObject *self, PyObject *args);
 static PyObject* binary_c_return_arglines(PyObject *self, PyObject *args);
 
-
-    
 /*
  * Python 3 interface is described at
  *
  * http://scipy-lectures.org/advanced/interfacing_with_c/interfacing_with_c.html
  */
 
+
 static PyMethodDef module_methods[] = {
 #ifdef __DEPRECATED
-    {"create_binary", binary_c_create_binary, METH_VARARGS, create_binary_docstring},
+    {"create_binary", 
+        binary_c_create_binary, 
+        METH_VARARGS, 
+        create_binary_docstring
+    },
 #endif
     {"run_binary", binary_c_run_binary, METH_VARARGS, run_binary_docstring},
-    {"run_binary_with_log", binary_c_run_binary_with_log, METH_VARARGS, run_binary_with_logdocstring},
+    {"run_binary_with_logfile", binary_c_run_binary_with_logfile, METH_VARARGS, run_binary_with_logdocstring},
+    {"run_binary_custom_logging", binary_c_run_binary_custom_logging, METH_VARARGS, run_binary_custom_loggingdocstring},
     {"function_prototype", binary_c_function_prototype, METH_VARARGS, function_prototype_docstring},
     {"new_system", binary_c_new_binary_system, METH_VARARGS, new_binary_system_docstring},
     {"return_arglines", binary_c_return_arglines, METH_VARARGS, return_arglines_docstring},
@@ -74,7 +82,6 @@ static PyMethodDef module_methods[] = {
 #if PY_MAJOR_VERSION >= 3
 
 /* Python 3+ */
-
 static struct PyModuleDef Py_binary_c =
 {
     PyModuleDef_HEAD_INIT,
@@ -97,7 +104,6 @@ PyMODINIT_FUNC PyInit_binary_c(void)
  * NOT TESTED THOROUGHLY!
  */
 
-
 PyMODINIT_FUNC initbinary_c(void)
 {
     PyObject *m = Py_InitModule3("binary_c", module_methods, module_docstring);
@@ -153,9 +159,11 @@ static PyObject* binary_c_new_binary_system(PyObject *self, PyObject *args)
     return ret;
 }
 
-
 static PyObject* binary_c_function_prototype(PyObject *self, PyObject *args)
 {
+
+    // This function is an very bare example of how a function would look like.
+
     double var1, var2;
 
     /* Parse the input tuple */
@@ -171,7 +179,6 @@ static PyObject* binary_c_function_prototype(PyObject *self, PyObject *args)
     }
 }
 
-
 static PyObject* binary_c_run_binary(PyObject *self, PyObject *args)
 {
     /* Parse the input tuple */
@@ -184,18 +191,77 @@ static PyObject* binary_c_run_binary(PyObject *self, PyObject *args)
     else
     {
         char * buffer;
-        int nbytes;
+        char * error_buffer;
+        size_t nbytes;
         int out MAYBE_UNUSED = run_binary(argstring,
                                           &buffer,
+                                          &error_buffer,
                                           &nbytes);
         /* copy the buffer to a python string */
-        PyObject * ret = Py_BuildValue("s", buffer);
-        free(buffer);
-        return ret;
+        PyObject * return_string = Py_BuildValue("s", buffer);
+        PyObject * return_error_string MAYBE_UNUSED = Py_BuildValue("s", error_buffer);
+
+        if(error_buffer != NULL && strlen(error_buffer)>0)
+        {
+            fprintf(stderr,
+                    "Error in binary_c run : %s\n",
+                    error_buffer);
+        }
+        
+        Safe_free(buffer);
+        Safe_free(error_buffer);
+
+        /* 
+         * TODO
+         * return the return_error_string as well!
+         */
+        return return_string;
+    }
+}
+
+static PyObject* binary_c_run_binary_custom_logging(PyObject *self, PyObject *args)
+{
+    /* Parse the input tuple */
+    char *argstring;
+    long int func_memaddr;
+
+    if(!PyArg_ParseTuple(args, "sl", &argstring, &func_memaddr))
+    {
+        return NULL;
+    }
+    else
+    {
+        char * buffer;
+        char * error_buffer;
+        size_t nbytes;
+        int out MAYBE_UNUSED = run_binary_custom_logging(argstring,
+                                          func_memaddr, 
+                                          &buffer,
+                                          &error_buffer,
+                                          &nbytes);
+        /* copy the buffer to a python string */
+        PyObject * return_string = Py_BuildValue("s", buffer);
+        PyObject * return_error_string MAYBE_UNUSED = Py_BuildValue("s", error_buffer);
+
+        if(error_buffer != NULL && strlen(error_buffer)>0)
+        {
+            fprintf(stderr,
+                    "Error in binary_c run : %s\n",
+                    error_buffer);
+        }
+        
+        Safe_free(buffer);
+        Safe_free(error_buffer);
+
+        /* 
+         * TODO
+         * return the return_error_string as well!
+         */
+        return return_string;
     }
 }
 
-static PyObject* binary_c_run_binary_with_log(PyObject *self, PyObject *args)
+static PyObject* binary_c_run_binary_with_logfile(PyObject *self, PyObject *args)
 {
     /* Parse the input tuple */
     char *argstring;
@@ -207,27 +273,61 @@ static PyObject* binary_c_run_binary_with_log(PyObject *self, PyObject *args)
     else
     {
         char * buffer;
-        int nbytes;
-        int out MAYBE_UNUSED = run_binary_with_log(argstring,
+        char * error_buffer;
+        size_t nbytes;
+        int out MAYBE_UNUSED = run_binary_with_logfile(argstring,
                                           &buffer,
+                                          &error_buffer,
                                           &nbytes);
+
         /* copy the buffer to a python string */
-        PyObject * ret = Py_BuildValue("s", buffer);
-        free(buffer);
-        return ret;
+        PyObject * return_string = Py_BuildValue("s", buffer);
+        PyObject * return_error_string MAYBE_UNUSED = Py_BuildValue("s", error_buffer);
+
+        if(error_buffer != NULL && strlen(error_buffer)>0)
+        {
+            fprintf(stderr,
+                    "Error in binary_c run : %s\n",
+                    error_buffer);
+        }
+        
+        Safe_free(buffer);
+        Safe_free(error_buffer);
+
+        /* 
+         * TODO
+         * return the return_error_string as well!
+         */
+        return return_string;
     }
 }
 
 static PyObject* binary_c_return_arglines(PyObject *self, PyObject *args)
 {
-    /* Binary structures */
     char * buffer;
-    int nbytes;
+    char * error_buffer;
+    size_t nbytes;
     int out MAYBE_UNUSED = return_arglines(&buffer,
-                                      &nbytes);
+                                          &error_buffer,
+                                          &nbytes);
+
     /* copy the buffer to a python string */
-    PyObject * ret = Py_BuildValue("s", buffer);
-    free(buffer);
-    /* Return an object containing the arg list */
-    return ret;
-}
\ No newline at end of file
+    PyObject * return_string = Py_BuildValue("s", buffer);
+    PyObject * return_error_string MAYBE_UNUSED = Py_BuildValue("s", error_buffer);
+
+    if(error_buffer != NULL && strlen(error_buffer)>0)
+    {
+        fprintf(stderr,
+                "Error in binary_c run : %s\n",
+                error_buffer);
+    }
+    
+    Safe_free(buffer);
+    Safe_free(error_buffer);
+
+    /* 
+     * TODO
+     * return the return_error_string as well!
+     */
+    return return_string;
+}
diff --git a/binary_c_python.h b/binary_c_python.h
index d4381f6885e5596556dc5bda3291af5e3540a7d7..29979236ed26c9929c013c4f34a8b6fb5d75f2f0 100644
--- a/binary_c_python.h
+++ b/binary_c_python.h
@@ -10,17 +10,24 @@
 
 /* Binary_c's python API prototypes */
 int run_binary (char * argstring,
-                char ** outstring,
-                int * nbytes);
-
-int run_binary_with_log (char * argstring,
-                char ** outstring,
-                int * nbytes);
-
-
-
-int return_arglines(char ** buffer,
-               int * nbytes);
+                char ** const outstring,
+                char ** const errorstring,
+                size_t * const nbytes);
+
+int run_binary_with_logfile (char * argstring,
+                char ** const outstring,
+                char ** const errorstring,
+                size_t * const nbytes);
+
+int run_binary_custom_logging(char * argstring,
+               long int func_memaddr,
+               char ** const buffer,
+               char ** const error_buffer,
+               size_t * const nbytes);
+
+int return_arglines(char ** const outstring,
+                char ** const errorstring,  
+                size_t * const nbytes);
 
 /* C macros */
 #define BINARY_C_APITEST_VERSION 0.1
diff --git a/binary_c_python_api.c b/binary_c_python_api.c
index 511516859613aa2d1f1ae5584164f09f6355dba3..309fc39a3db639fdc627178e4ee5c27d26e8a5d1 100644
--- a/binary_c_python_api.c
+++ b/binary_c_python_api.c
@@ -35,49 +35,72 @@
  * I have tested this with gcc 4.7.2 (Ubuntu 12.10) only.
  */
 
-
 // #define _CAPTURE
 #ifdef _CAPTURE
 static void show_stdout(void);
 static void capture_stdout(void);
 #endif
 
-
 /* global variables */
 int out_pipe[2];
 int stdoutwas;
 
-int main(int argc,
-         char * argv[])
+int run_binary(char * argstring,
+               char ** const buffer,
+               char ** const error_buffer,
+               size_t * const nbytes)
 {
-    char * argstring = MALLOC(sizeof(char) * (size_t)STRING_LENGTH);
-    snprintf(argstring,
-             STRING_LENGTH,
-             "binary_c M_1 %g M_2 %g separation %g orbital_period %g metallicity %g max_evolution_time %g\n",
-             20.0,
-             15.0,
-             0.0,
-             3.0,
-             0.02,
-             15000.0);
-
-    char * buffer ;
-    int nbytes;
-    int out = run_binary(argstring,
-                         &buffer,
-                         &nbytes);
+    /* memory for N binary systems */
+    struct libbinary_c_stardata_t *stardata;
+    struct libbinary_c_store_t * store = NULL;
+
+    /* make new stardata */
+    stardata = NULL;
+    binary_c_new_system(&stardata,
+                        NULL,
+                        NULL,
+                        &store,
+                        &argstring,
+                        -1);
     
-    printf("output (binary_c returned %d)\n%s\n",out,buffer);
+    /* disable logging */
+    snprintf(stardata->preferences->log_filename,
+             STRING_LENGTH-1,
+             "%s",
+             "/dev/null");
+    snprintf(stardata->preferences->api_log_filename_prefix,
+             STRING_LENGTH-1,
+             "%s",
+             "/dev/null");
+    /* output to strings */
+    stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
+    stardata->preferences->batchmode = BATCHMODE_LIBRARY;
 
-    free(buffer);
+    /* do binary evolution */
+    binary_c_evolve_for_dt(stardata,
+                           stardata->model.max_evolution_time);
+        
+    /* get buffer pointer */
+    binary_c_buffer_info(stardata,buffer,nbytes);
     
-    return out;
+    /* get error buffer pointer */
+    binary_c_error_buffer(stardata,error_buffer);
+    
+    /* set raw_buffer_size = -1 to prevent it being freed */
+    stardata->tmpstore->raw_buffer_size = -1;
+    
+    /* free stardata (except the buffer) */
+    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE,FALSE);
+    binary_c_free_store_contents(store);
+        
+    return 0;
 }
 
-
-int run_binary(char * argstring,
-               char ** buffer,
-               int * nbytes)
+int run_binary_custom_logging(char * argstring,
+               long int func_memaddr,
+               char ** const buffer,
+               char ** const error_buffer,
+               size_t * const nbytes)
 {
     /* memory for N binary systems */
     struct libbinary_c_stardata_t *stardata;
@@ -91,6 +114,7 @@ int run_binary(char * argstring,
                         &store,
                         &argstring,
                         -1);
+    
     /* disable logging */
     snprintf(stardata->preferences->log_filename,
              STRING_LENGTH-1,
@@ -101,28 +125,33 @@ int run_binary(char * argstring,
              "%s",
              "/dev/null");
     /* output to strings */
-    stardata->preferences->internal_buffering = 2;
-    stardata->preferences->internal_buffering_compression = 0;
+    stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
     stardata->preferences->batchmode = BATCHMODE_LIBRARY;
+    stardata->preferences->custom_output_function = (void*)(struct stardata_t *)func_memaddr;
 
     /* do binary evolution */
     binary_c_evolve_for_dt(stardata,
                            stardata->model.max_evolution_time);
-
+        
     /* get buffer pointer */
     binary_c_buffer_info(stardata,buffer,nbytes);
-
+    
+    /* get error buffer pointer */
+    binary_c_error_buffer(stardata,error_buffer);
+    
     /* set raw_buffer_size = -1 to prevent it being freed */
     stardata->tmpstore->raw_buffer_size = -1;
     
     /* free stardata (except the buffer) */
-    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE);
+    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE,FALSE);
     binary_c_free_store_contents(store);
+        
     return 0;
 }
 
-int return_arglines(char ** buffer,
-                    int * nbytes)
+int return_arglines(char ** const buffer,
+               char ** const error_buffer,
+               size_t * const nbytes)
 {
     /* memory for N binary systems */
     struct libbinary_c_stardata_t *stardata;
@@ -149,8 +178,7 @@ int return_arglines(char ** buffer,
              "/dev/null");
 
     /* output to strings */
-    stardata->preferences->internal_buffering = 2;
-    stardata->preferences->internal_buffering_compression = 0;
+    stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
     stardata->preferences->batchmode = BATCHMODE_LIBRARY;
 
     /* List available arguments */
@@ -158,19 +186,24 @@ int return_arglines(char ** buffer,
 
     /* get buffer pointer */
     binary_c_buffer_info(stardata,buffer,nbytes);
-
+    
+    /* get error buffer pointer */
+    binary_c_error_buffer(stardata,error_buffer);
+    
     /* set raw_buffer_size = -1 to prevent it being freed */
     stardata->tmpstore->raw_buffer_size = -1;
     
     /* free stardata (except the buffer) */
-    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE);
+    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE,FALSE);
     binary_c_free_store_contents(store);
+
     return 0;
 }
 
-int run_binary_with_log(char * argstring,
-               char ** buffer,
-               int * nbytes)
+int run_binary_with_logfile(char * argstring,
+               char ** const buffer,
+               char ** const error_buffer,
+               size_t * const nbytes)
 {
     /* memory for N binary systems */
     struct libbinary_c_stardata_t *stardata;
@@ -184,34 +217,26 @@ int run_binary_with_log(char * argstring,
                         &store,
                         &argstring,
                         -1);
-    /* disable logging */
-    // snprintf(stardata->preferences->log_filename,
-    //          STRING_LENGTH-1,
-    //          "%s",
-    //          "/dev/null");
-    // snprintf(stardata->preferences->api_log_filename_prefix,
-    //          STRING_LENGTH-1,
-    //          "%s",
-    //          "/dev/null");
+
     /* output to strings */
-    stardata->preferences->internal_buffering = 2;
-    stardata->preferences->internal_buffering_compression = 0;
+    stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
     stardata->preferences->batchmode = BATCHMODE_LIBRARY;
 
     /* do binary evolution */
     binary_c_evolve_for_dt(stardata,
                            stardata->model.max_evolution_time);
-
+        
     /* get buffer pointer */
     binary_c_buffer_info(stardata,buffer,nbytes);
-
+    
+    /* get error buffer pointer */
+    binary_c_error_buffer(stardata,error_buffer);
+    
     /* set raw_buffer_size = -1 to prevent it being freed */
     stardata->tmpstore->raw_buffer_size = -1;
     
     /* free stardata (except the buffer) */
-    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE);
+    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE,FALSE);
     binary_c_free_store_contents(store);
     return 0;
 }
-
-
diff --git a/binaryc_python_utils/custom_logging_functions.py b/binaryc_python_utils/custom_logging_functions.py
new file mode 100644
index 0000000000000000000000000000000000000000..2d82f67b1839ab4d7c23b5b01790c3f1f5c2fbc1
--- /dev/null
+++ b/binaryc_python_utils/custom_logging_functions.py
@@ -0,0 +1,276 @@
+import os
+import textwrap
+import subprocess
+import socket
+import tempfile
+import ctypes
+
+# Functions for the automatic logging of stuff
+def autogen_C_logging_code(logging_dict):
+    # See example_perl.pm autologging
+    """
+    Function that autogenerates PRINTF statements for binaryc
+
+    Input:
+        dictionary where the key is the header of that logging line and items which are lists of parameters that will be put in that logging line
+
+        example: {'MY_STELLAR_DATA': 
+        [
+            'model.time',
+            'star[0].mass',
+            'model.probability',
+            'model.dt'
+        ']}
+    """
+
+    # Check if the input is of the correct form 
+    if not type(logging_dict)==dict:
+        print("Error: please use a dictionary as input")
+        return None
+
+    code = ''
+    # Loop over dict keys
+    for key in logging_dict:
+        logging_dict_entry = logging_dict[key]
+
+        # Check if item is of correct type:
+        if type(logging_dict_entry)==list:
+
+            # Construct print statement
+            code += 'Printf("{}'.format(key)
+            code += ' {}'.format('%g '*len(logging_dict_entry))
+            code = code.strip()
+            code += '\\n"'
+
+            # Add format keys
+            for param in logging_dict_entry:
+                code += ',((double)stardata->{})'.format(param)
+            code += ');\n'
+
+        else:
+            print('Error: please use a list for the list of parameters that you want to have logged')
+    code = code.strip()
+    # print("MADE AUTO CODE\n\n{}\n\n{}\n\n{}\n".format('*'*60, repr(code), '*'*60))
+
+    return code
+
+####################################################################################
+def binary_c_log_code(code):
+    """
+    Function to construct the code to construct the custom logging function
+    # see example_perl.pm binary_c_log_code in perl
+    """
+    custom_logging_function_string = """\
+#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;
+    {};
+}}
+
+#undef MAX 
+#undef MIN
+#pragma pop_macro(\"MIN\")
+#pragma pop_macro(\"MAX\")\
+    """.format(code)
+     
+    # print(repr(textwrap.dedent(custom_logging_function_string)))
+    return textwrap.dedent(custom_logging_function_string)
+
+def binary_c_write_log_code(code, filename):
+    """
+    Function to write the generated logging code to a file
+    """
+
+    cwd = os.getcwd()
+
+    filePath = os.path.join(cwd, filename)
+    if os.path.exists(filePath):
+        try:
+            os.remove(filePath)
+        except:
+            print("Error while deleting file {}".format(filePath))
+
+    with open(filePath, 'w') as f:
+        f.write(code)
+
+def from_binary_c_config(config_file, flag):
+    """
+    Function to run the binaryc_config command with flags
+    """
+
+    res = subprocess.check_output('{config_file} {flag}'.format(config_file=config_file, flag=flag),
+        shell=True, stderr=subprocess.STDOUT)
+
+    # convert and chop off newline
+    res = res.decode('utf').rstrip()
+    return res
+
+def return_compilation_dict():
+    """
+    Function to build the compile command for the shared library
+
+    inspired by binary_c_inline_config command in perl
+
+    TODO: this function still has some cleaning up to do wrt default values for the compile command
+    # https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
+
+
+    returns:
+     - string containing the command to build the shared library
+    """    
+
+    # use binary_c-config to get necessary flags
+    BINARY_C_DIR = os.getenv('BINARY_C')
+    if BINARY_C_DIR:
+        BINARY_C_CONFIG = os.path.join(BINARY_C_DIR, 'binary_c-config')
+        BINARY_C_SRC_DIR = os.path.join(BINARY_C_DIR, 'src')
+        # TODO: build in check to see whether the file exists
+    else:
+        raise NameError('Envvar BINARY_C doesnt exist')
+        return None
+
+    # TODO: make more options for the compiling
+    cc = from_binary_c_config(BINARY_C_CONFIG, 'cc')
+
+    # Check for binary_c
+    BINARY_C_EXE = os.path.join(BINARY_C_DIR, 'binary_c')
+    if not os.path.isfile(BINARY_C_EXE):
+        print("We require  binary_c executable; have you built binary_c?")
+        raise NameError('BINARY_C executable doesnt exist')
+
+    # TODO: debug
+    libbinary_c = '-lbinary_c'
+    binclibs = from_binary_c_config(BINARY_C_CONFIG, 'libs')
+    libdirs = "{} -L{}".format(from_binary_c_config(BINARY_C_CONFIG, 'libdirs'), BINARY_C_SRC_DIR)
+    bincflags = from_binary_c_config(BINARY_C_CONFIG, 'cflags')
+    bincincdirs = from_binary_c_config(BINARY_C_CONFIG, 'incdirs')
+
+    # combine 
+    binclibs = ' {} {} {}'.format(libdirs, libbinary_c, binclibs)
+
+    # setup defaults:
+    defaults = {
+        'cc': 'gcc', # default compiler
+        'ccflags': bincflags,
+        'ld': 'ld',         # 'ld': $Config{ld}, # default linker
+        'debug': 0,
+        'inc': '{} -I{}'.format(bincincdirs, BINARY_C_SRC_DIR),
+        # inc => ' '.($Config{inc}//' ').' '.$bincincdirs." -I$srcdir ", # include the defaults plus # GSL and binary_c
+        # 'libname': libname, # libname is usually just binary_c corresponding to libbinary_c.so
+        'libs': binclibs,
+    }
+
+    # set values with defaults. TODO: make other input possile.
+    ld = defaults['ld']
+    debug = defaults['debug']
+    inc = defaults['inc'] # = ($ENV{BINARY_GRID2_INC} // $defaults{inc}).' '.($ENV{BINARY_GRID2_EXTRAINC} // '');
+    libs = defaults['libs'] # = ($ENV{BINARY_GRID2_LIBS} // $defaults{libs}).' '.($ENV{BINARY_GRID2_EXTRALIBS}//'');
+    ccflags = defaults['ccflags'] #  = $ENV{BINARY_GRID2_CCFLAGS} // ($defaults{ccflags}) . ($ENV{BINARY_GRID2_EXTRACCFLAGS} // '');
+  
+    # you must define _SEARCH_H to prevent it being loaded twice
+    ccflags += ' -shared -D_SEARCH_H'
+
+    # remove the visibility=hidden for this compilation
+    ccflags = ccflags.replace('-fvisibility=hidden', '')
+
+
+    # ensure library paths to the front of the libs:
+    libs_content = libs.split(' ')
+    library_paths = [el for el in libs_content if el.startswith('-L')]
+    non_library_paths = [el for el in libs_content if (not el.startswith('-L') and not el=='')]
+    libs = "{} {}".format(' '.join(library_paths), ' '.join(non_library_paths))
+
+    print("Building shared library for custom logging with (binary_c.h) at {} on {}\n".format(BINARY_C_SRC_DIR, socket.gethostname()))
+    print("With options:\n\tcc = {cc}\n\tccflags = {ccflags}\n\tld = {ld}\n\tlibs = {libs}\n\tinc = {inc}\n\n".format(
+        cc=cc, ccflags=ccflags, ld=ld, libs=libs, inc=inc)
+    )
+
+    return {
+        'cc': cc,
+        'ld': ld,
+        'ccflags': ccflags,
+        'libs': libs,
+        'inc': inc
+        }
+
+def compile_shared_lib(code, sourcefile_name, outfile_name):
+    """
+    Function to write the custom logging code to a file and then compile it.
+    """
+
+    # Write code to file
+    binary_c_write_log_code(code, sourcefile_name)
+
+    # create compilation command
+    compilation_dict = return_compilation_dict()
+
+    # Construct full command
+    command = "{cc} {ccflags} {libs} -o {outfile_name} {sourcefile_name} {inc}".format(
+        cc=compilation_dict['cc'],
+        ccflags=compilation_dict['ccflags'],
+        libs=compilation_dict['libs'],
+        outfile_name=outfile_name,
+        sourcefile_name=sourcefile_name,
+        inc=compilation_dict['inc'])
+
+    # remove extra whitespaces:
+    command = ' '.join(command.split())
+
+    # Execute compilation
+    print('Executing following command:\n{command}'.format(command=command))
+    res = subprocess.check_output('{command}'.format(command=command),
+        shell=True)
+
+    if res:
+        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
+
+
+def create_and_load_logging_function(custom_logging_code):
+    """
+    Function to automatically compile the shared library with the given custom logging code and load it with ctypes
+
+    returns:
+        memory adress of the custom logging function in a int type.
+    """
+
+    # 
+    compile_shared_lib(custom_logging_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(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
+    func_memaddr = ctypes.cast(libmean.custom_output_function, ctypes.c_void_p).value
+
+    return func_memaddr
diff --git a/binaryc_python_utils/defaults.py b/binaryc_python_utils/defaults.py
deleted file mode 100644
index aba0d28e9bb06819c8280885ae788180416a275d..0000000000000000000000000000000000000000
--- a/binaryc_python_utils/defaults.py
+++ /dev/null
@@ -1,379 +0,0 @@
-# WARNING DEPRECATED FROM 11-aug-2019
-
-# File containing physics_defaults
-physics_defaults = {
-    
-    # internal buffering and compression level
-    'internal_buffering': 0,
-    'internal_buffering_compression': 0,
-    
-    # log filename
-    'log_filename': '/dev/null',
-
-    'metallicity': 0.02, # metallicity (default 0.02, solar)
-    'max_evolution_time': 13700.0, # max evol time in Myr (default WMAP result)
-
-    # stellar evolution parameters
-    'max_tpagb_core_mass': 1.38,
-    'chandrasekhar_mass': 1.44,
-    'max_neutron_star_mass': 1.8,
-    'minimum_mass_for_carbon_ignition': 1.6,
-    'minimum_mass_for_neon_ignition': 2.85,
-    'AGB_core_algorithm': 0,
-    'AGB_radius_algorithm': 0,
-    'AGB_luminosity_algorithm': 0,
-    'AGB_3dup_algorithm': 0,
-
-    # dredge up calibration (either automatic, or not)
-    'delta_mcmin': 0.0,
-    'lambda_min': 0.0,
-    'minimum_envelope_mass_for_third_dredgeup': 0.5,
-
-    # minimum timestep (1yr = 1e-6 is the default)
-    'minimum_timestep': 1e-6,
-    # maximum timestep (1 Gyr = 1e3 is the default)
-    'maximum_timestep': 1e3,
-
-    # orbit
-    'eccentricity': 0.0,
-
-    # tidally induced mass loss
-    'CRAP_parameter': 0.0,
-    
-    # tidal strength factor
-    'tidal_strength_factor': 1.0,
-
-    # E2 tidal prescription. 0 = H02, 1 = Siess+2013
-    'E2_prescription': 1, 
-
-    # gravitational radiation model
-    # 0 = H02 model (Eggleton) for J and e
-    # 1 = H02 when R<RL for both stars for J and e
-    # 2 = None
-    # 3 = Landau and Lifshitz (1951) model for J (e is not changed)
-    # 4 = Landau and Lifshitz (1951) model for J when R<RL only (e is not changed)
-    'gravitational_radiation_model': 0,
-
-    # magnetic braking multiplier
-    'magnetic_braking_factor': 1.0,
-
-    ############################################################
-    ### Mass-loss prescriptions
-    ############################################################
-
-    # turn wind mass loss on or off
-    'wind_mass_loss': 1,
-
-    # massive stars
-    'wr_wind': 0, # default hurley et al wind
-    'wr_wind_fac': 1.0, # factor applied to WR stars
-    
-    # TPAGB wind details
-    'tpagbwind': 0, # default to 0 (Karakas et al 2002)
-    'superwind_mira_switchon': 500.0,
-    'tpagb_reimers_eta': 1.0,
-
-    # eta for Reimers-like GB mass loss
-    'gb_reimers_eta': 0.5,
-
-    # VW93 alterations
-    'vw93_mira_shift': 0.0,
-    'vw93_multiplier': 1.0,
-
-    # systemic wind angular momentum loss prescription
-    'wind_angular_momentum_loss': 0,
-    'lw': 1.0,
-
-    # enhanced mass loss due to rotation
-    # 0 = none = ROTATION_ML_NONE
-    # 1 = Langer+ formula (in mass-loss rate calculation, 
-    #                      warning: can be unstable 
-    #                      = ROTATION_ML_FORMULA)
-    # 2 = remove material in a decretion disc until J<Jcrit
-    #     (ROTATION_ML_ANGMOM)
-    # 3 = 1 + 2 (not recommended!)
-    'rotationally_enhanced_mass_loss': 2,
-    'rotationally_enhanced_exponent': 1.0,
-
-    # timestep modulator
-    'timestep_modulator': 1.0,
-
-    # initial rotation rates (0=automatic, >0 = in km/s)
-    'vrot1': 0.0,
-    'vrot2': 0.0,
-
-    ########################################
-    # Supernovae and kicks
-    ########################################
-
-    # Black hole masses: 
-    # 0: H02=0
-    # 1: Belczynski
-    # 2: Spera+ 2015
-    # 3: Fryer 2012 (delayed)
-    # 4: Fryer 2012 (rapid)
-    'BH_prescription': 2,
-    'post_SN_orbit_method': 0,
-
-    'wd_sigma': 0.0,
-    'wd_kick_direction': 0,
-    'wd_kick_pulse_number': 0,
-    'wd_kick_when': 0,
-
-    # sn_kick_distribution and 
-    # sn_kick_dispersion are only defined 
-    # for SN types that leave a remnant
-    'sn_kick_distribution_II': 1,
-    'sn_kick_dispersion_II': 190.0,
-    'sn_kick_distribution_IBC': 1,
-    'sn_kick_dispersion_IBC': 190.0,
-    'sn_kick_distribution_GRB_COLLAPSAR': 1,
-    'sn_kick_dispersion_GRB_COLLAPSAR': 190.0,
-    'sn_kick_distribution_ECAP': 1,
-    'sn_kick_dispersion_ECAP': 190.0,
-    'sn_kick_distribution_NS_NS': 0,
-    'sn_kick_dispersion_NS_NS': 0.0,
-    'sn_kick_distribution_TZ': 0,
-    'sn_kick_dispersion_TZ': 0.0,
-    'sn_kick_distribution_BH_BH': 0,
-    'sn_kick_dispersion_BH_BH': 0.0,
-    'sn_kick_distribution_BH_NS': 0,
-    'sn_kick_dispersion_BH_NS': 0.0,
-    'sn_kick_distribution_AIC_BH': 0,
-    'sn_kick_dispersion_AIC_BH': 0.0,
-
-    'sn_kick_companion_IA_He': 0,
-    'sn_kick_companion_IA_ELD': 0,
-    'sn_kick_companion_IA_CHAND': 0,
-    'sn_kick_companion_AIC': 0,
-    'sn_kick_companion_ECAP': 0,
-    'sn_kick_companion_IA_He_Coal': 0,
-    'sn_kick_companion_IA_CHAND_Coal': 0,
-    'sn_kick_companion_NS_NS': 0,
-    'sn_kick_companion_GRB_COLLAPSAR': 0,
-    'sn_kick_companion_HeStarIa': 0,
-    'sn_kick_companion_IBC': 0,
-    'sn_kick_companion_II': 0,
-    'sn_kick_companion_IIa': 0,
-    'sn_kick_companion_WDKICK': 0,
-    'sn_kick_companion_TZ': 0,
-    'sn_kick_companion_AIC_BH': 0,
-    'sn_kick_companion_BH_BH': 0,
-    'sn_kick_companion_BH_NS': 0,
-
-    # evolution run splitting
-    'evolution_splitting': 0,
-    'evolution_splitting_sn_n': 10,
-    'evolution_splitting_maxdepth': 1,
-
-    ########################################
-    #### Mass transfer 
-    ########################################
-
-    # critical mass ratio for unstable RLOF 
-    #
-    # qc = m (donor) / m (accretor) : 
-    # if q>qc mass transfer is unstable
-    #
-    # H02 = Hurley et al. (2002)
-    # C14 = Claeys et al. (2014)
-
-    # non-degenerate accretors
-    'qcrit_LMMS': 0.6944, # de Mink et al 2007 suggests 1.8, C14 suggest 1/1.44 = 0.694
-    'qcrit_MS': 1.6, # C14 suggest 1.6
-    'qcrit_HG': 4.0, # H02 sect. 2.6.1 gives 4.0
-    'qcrit_GB': -1, # -1 is the H02 prescription for giants
-    'qcrit_CHeB': 3.0, 
-    'qcrit_EAGB': -1, # -1 is the H02 prescription for giants
-    'qcrit_TPAGB': -1, # -1 is the H02 prescription for giants
-    'qcrit_HeMS': 3,
-    'qcrit_HeHG': 0.784, # as in H02 2.6.1
-    'qcrit_HeGB': 0.784, # as in H02 2.6.1
-    'qcrit_HeWD': 3, # H02
-    'qcrit_COWD': 3, # H02
-    'qcrit_ONeWD': 3, # H02
-    'qcrit_NS': 3, # H02
-    'qcrit_BH': 3, # H02
-
-    # degenerate accretors
-    'qcrit_degenerate_LMMS': 1.0, # C14
-    'qcrit_degenerate_MS': 1.0, # C14
-    'qcrit_degenerate_HG': 4.7619, # C14
-    'qcrit_degenerate_GB': 1.15, # C14 (based on Hachisu)
-    'qcrit_degenerate_CHeB': 3, # not used
-    'qcrit_degenerate_EAGB': 1.15, # as GB
-    'qcrit_degenerate_TPAGB': 1.15, # as GB
-    'qcrit_degenerate_HeMS': 3,
-    'qcrit_degenerate_HeHG': 4.7619, # C14
-    'qcrit_degenerate_HeGB': 1.15, # C14
-    'qcrit_degenerate_HeWD': 0.625, # C14
-    'qcrit_degenerate_COWD': 0.625, # C14
-    'qcrit_degenerate_ONeWD': 0.625, # C14
-    'qcrit_degenerate_NS': 0.625, # C14
-    'qcrit_degenerate_BH': 0.625, # C14
-
-    # disk wind for SNeIa
-    'hachisu_disk_wind': 0, # 0 
-    'hachisu_qcrit': 1.15, # 1.15
-
-    # ELD accretion mass
-    'mass_accretion_for_eld': 0.15, # 0.15, or 100(off)
-
-    # mergers have the critical angular momentum
-    # multiplied by this factor
-    'merger_angular_momentum_factor': 1.0,
-
-    # RLOF rate method : 0=H02, 1=Adaptive R=RL, 3=Claeys et al 2014
-    'RLOF_method': 3,
-    'RLOF_mdot_factor': 1.0,
-
-    # RLOF time interpolation method
-    # 0 = binary_c (forward in time only), 1 = BSE (backwards allowed)
-    'RLOF_interpolation_method': 0,
-
-    # Angular momentum in RLOF transfer model
-    # 0 : H02 (including disk treatment)
-    # 1 : Conservative
-    'jorb_RLOF_transfer_model': 0,
-
-    # ang mom factor for non-conservative mass loss
-    # -2 : a wind from the secondary (accretor), i.e. gamma=Md/Ma (default in C14)
-    # -1 : donor (alternative in C14), i.e. gamma=Ma/Md
-    # >=0 : the specific angular momentum of the orbit multiplied by gamma
-    #
-    # (NB if Hachisu's disk wind is active, or loss is because of
-    # super-Eddington accretion or novae, material lost through the 
-    #  disk wind automatically gets gamma=-2 i.e. the Jaccretor) 
-    'nonconservative_angmom_gamma': -2,
-
-    # Hachisu's disc wind
-    'hachisu_disk_wind': 0,
-    'hachisu_qcrit': -1.0,
-
-    # donor rate limiters
-    'donor_limit_thermal_multiplier': 1.0,
-    'donor_limit_dynamical_multiplier': 1.0,
-
-    # RLOF assumes circular orbit (0) or at periastron (1)
-    'rlperi': 0,
-
-    # general accretion limits
-    'accretion_limit_eddington_multiplier': 1.0, # eddington limit factor
-    'accretion_limit_dynamical_multiplier': 1.0, # dynamical limit factor
-    'accretion_limit_thermal_multiplier': 1.0, # thermal limit on MS,HG and CHeB star factor
-    'accretion_rate_novae_upper_limit': 1.03e-7,
-    'accretion_rate_soft_xray_upper_limit': 2.71e-7,
-
-    # novae
-    'nova_retention_method': 0,
-    'nova_retention_fraction': 1e-3,
-    'individual_novae': 0,
-    'beta_reverse_nova': -1,
-    'nova_faml_multiplier': 1.0,
-    'nova_irradiation_multiplier': 0.0,
-
-    ########################################
-    # common envelope evolution
-    ########################################
-    'comenv_prescription': 0, # 0=H02, 1=nelemans, 2=Nandez+Ivanova2016
-    'alpha_ce': 1.0,
-    'lambda_ce': -1, # -1 = automatically set
-    'lambda_ionisation': 0.0,
-    'lambda_enthalpy': 0.0,
-    'comenv_splitmass': 0.0,
-    'comenv_ms_accretion_mass': 0.0,
-    'nelemans_minq': 0.0, # 0.0 min q for nelemans
-    'nelemans_max_frac_j_change': 1.0, # 1.0
-    'nelemans_gamma': 1.0, # 1.0
-    'nelemans_n_comenvs': 1, # 1
-    'comenv_merger_spin_method': 2,
-    'comenv_ejection_spin_method': 1,
-    'comenv_post_eccentricity': 0.0,
-    'comenv_splitmass': 1.01,
-
-    # comenv accretion
-    'comenv_ns_accretion_fraction': 0.0,
-    'comenv_ns_accretion_mass': 0.0,
-
-    # #################################################
-    # circumbinary disc
-    # #################################################
-    # 'comenv_disc_mass_fraction' :  0.0,
-    # 'comenv_disc_angmom_fraction' :  0.0,
-    # 'cbdisc_gamma' :  1.6666666666,
-    # 'cbdisc_alpha' :  1e-6,
-    # 'cbdisc_kappa' :  1e-2,
-    # 'cbdisc_torquef' :  1.0,
-    # 'cbdisc_mass_loss_constant_rate' :  0.0,
-    # 'cbdisc_mass_loss_inner_viscous_accretion_method' :  1,
-    # 'cbdisc_mass_loss_inner_viscous_multiplier' :  1.0,
-    # 'cbdisc_mass_loss_inner_L2_cross_multiplier' :  0.0,
-    # 'cbdisc_mass_loss_ISM_ram_pressure_multiplier' :  0.0,
-    # 'cbdisc_mass_loss_ISM_pressure' :  3000.0,
-    # 'cbdisc_mass_loss_FUV_multiplier' :  0.0,
-    # 'cbdisc_mass_loss_Xray_multiplier' :  1.0,
-    # 'cbdisc_viscous_photoevaporation_coupling' :  1,
-    # 'cbdisc_inner_edge_stripping' :  1,
-    # 'cbdisc_outer_edge_stripping' :  1,
-    # 'cbdisc_minimum_luminosity' :  1e-4,
-    # 'cbdisc_minimum_mass' :  1e-6,
-    # 'cbdisc_eccentricity_pumping_method' :  1,
-    # 'cbdisc_resonance_multiplier' :  1.0,
-    # 'comenv_post_eccentricity' :  1e-5,
-
-    ##################################################
-    # wind accretion
-    ##################################################
-
-    # Bondi-Hoyle accretion multiplier
-    'Bondi_Hoyle_accretion_factor': 1.5,
-    # Wind-RLOF method: 0=none, 1=q-dependent, 2=quadratic
-    # (See Abate et al. 2012,13,14 series of papers)
-    'WRLOF_method': 0,
-
-    # pre-main sequence evolution
-    'pre_main_sequence': 0,
-    'pre_main_sequence_fit_lobes': 0,
-
-    ########################################
-    # Nucleosynthesis
-    ########################################
-
-    # lithium
-    'lithium_hbb_multiplier': 1.0,
-    'lithium_GB_post_1DUP': 0.0,
-    'lithium_GB_post_Heflash': 0.0,
-
-    ########################################
-    # Yields vs time (GCE)
-    ########################################
-
-    'yields_dt': 100000,
-    'escape_velocity': 1e9, # if wind v < this, ignore the yield
-    # and assume it is lost to the IGM
-    'escape_fraction': 0.0, # assume all yield is kept in the population
-
-    # minimum sep/per for RLOF on the ZAMS
-    'minimum_separation_for_instant_RLOF': 0,
-    'minimum_orbital_period_for_instant_RLOF': 0, 
-}
-
-
-
-
-
-
-
-
-
-        
-
-
-    
-
-
-
-
-
-
-
diff --git a/binaryc_python_utils/functions.py b/binaryc_python_utils/functions.py
index 26bbf5e066533ef34c16bd1bfe4c56653ee185e0..b82c86f13ddab420f099598a0f34f72582282e63 100644
--- a/binaryc_python_utils/functions.py
+++ b/binaryc_python_utils/functions.py
@@ -1,7 +1,7 @@
-import binary_c
-
 from collections import defaultdict
-from binaryc_python_utils.defaults import physics_defaults
+
+import binary_c
+from binaryc_python_utils.custom_logging_functions import create_and_load_logging_function
 
 def create_arg_string(arg_dict):
     """
@@ -41,33 +41,60 @@ def get_arg_keys():
 def run_system(**kwargs):
     """
     Wrapper to run a system with settings 
+    
+    This function determines which underlying python-c api function will be called based upon the arguments that are passed via kwargs.
+
+    - if custom_logging_code or custom_logging_dict is included in the kwargs then it will     
+    - if 
+
     """
 
     # Load default args
     args = get_defaults()
-    # args = {}
+    if 'custom_logging_code' in kwargs:
+        # Use kwarg value to override defaults and add new args
+        for key in kwargs.keys():
+            if not key=='custom_logging_code':
+                args[key] = kwargs[key]
 
-    # For example
-    # physics_args['M_1'] = 20
-    # physics_args['separation'] = 0 # 0 = ignored, use period
-    # physics_args['orbital_period'] = 100000000000 # To make it single
+        # Generate library and get memaddr
+        func_memaddr = create_and_load_logging_function(kwargs['custom_logging_code'])
 
-    # Use kwarg value to override defaults and add new args
-    for key in kwargs.keys():
-        args[key] = kwargs[key]
+        # Construct arguments string and final execution string
+        arg_string = create_arg_string(args)
+        arg_string = 'binary_c {}'.format(arg_string)
 
-    # Construct arguments string and final execution string
-    arg_string = create_arg_string(args)
-    arg_string = f'binary_c {arg_string}' 
+        # Run it and get output
+        output = binary_c.run_binary_custom_logging(arg_string, func_memaddr)
+        return output
 
-    # print(arg_string)
+    elif 'log_filename' in kwargs:
+        # Use kwarg value to override defaults and add new args
+        for key in kwargs.keys():
+            args[key] = kwargs[key]
 
-    # Run it and get output
-    buffer = ""
-    output = binary_c.run_binary(arg_string)
+        # Construct arguments string and final execution string
+        arg_string = create_arg_string(args)
+        arg_string = 'binary_c {}'.format(arg_string)
 
-    return output
+        # Run it and get output
+        output = binary_c.run_binary_with_logfile(arg_string)
+        return output
+
+    else: # run the plain basic type
 
+        # Use kwarg value to override defaults and add new args
+        for key in kwargs.keys():
+            args[key] = kwargs[key]
+
+        # Construct arguments string and final execution string
+        arg_string = create_arg_string(args)
+        arg_string = 'binary_c {}'.format(arg_string)
+
+        # Run it and get output
+        output = binary_c.run_binary(arg_string)
+
+        return output
 
 def run_system_with_log(**kwargs):
     """
@@ -93,8 +120,7 @@ def run_system_with_log(**kwargs):
 
     # Construct arguments string and final execution string
     arg_string = create_arg_string(args)
-    arg_string = f'binary_c {arg_string}' 
-
+    arg_string = 'binary_c {}'.format(arg_string) 
     # print(arg_string)
 
     # Run it and get output
@@ -109,7 +135,9 @@ def parse_output(output, selected_header):
     DAVID_SINGLE_ANALYSIS t=0 mass=20 
 
     You can give a 'selected_header' to catch any line that starts with that. 
-    Then the values will be put into a 
+    Then the values will be put into a dictionary.
+    TODO: Think about exporting to numpy array or pandas
+
     """
     value_dicts = []
     val_lists = []
@@ -138,8 +166,6 @@ def parse_output(output, selected_header):
         print('Sorry, didnt find any line matching your header {}'.format(selected_header))
         return None
 
-
-
     keys = value_dicts[0].keys()
 
     # Construct final dict.
diff --git a/examples/.ipynb_checkpoints/example_notebook-checkpoint.ipynb b/examples/.ipynb_checkpoints/example_notebook-checkpoint.ipynb
deleted file mode 100644
index f9db89b1350c3f8d1bbbe76e95a65bffd733a9c1..0000000000000000000000000000000000000000
--- a/examples/.ipynb_checkpoints/example_notebook-checkpoint.ipynb
+++ /dev/null
@@ -1,165 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Example notebook binarypy"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "/user/HS128/dh00601/.pyenv/versions/3.6.4/envs/binaryc_py3.6.4/bin/python\n"
-     ]
-    }
-   ],
-   "source": [
-    "import os, sys\n",
-    "import matplotlib.pyplot as plt\n",
-    "import pandas as pd\n",
-    "\n",
-    "# Append root dir of this project to include functionality\n",
-    "print(sys.executable)\n",
-    "sys.path.append(os.path.dirname(os.getcwd()))\n",
-    "import binary_c\n",
-    "from utils.defaults import physics_defaults\n",
-    "from utils.functions import create_arg_string"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "def example_with_loading_default_args():\n",
-    "    \"\"\"\n",
-    "    Example function loading the default physics args for a binary_c system. Got\n",
-    "    it from the binary_grid2 perl module\n",
-    "\n",
-    "    This function works if binary_c is set to log something every timestep so that we can plot the evolution of a system\n",
-    "    \"\"\"\n",
-    "\n",
-    "    # Load args\n",
-    "    physics_args = physics_defaults.copy()\n",
-    "\n",
-    "    # Manually set M_1, M_2, orbital_period and separation values:\n",
-    "    physics_args['M_1'] = 20\n",
-    "    physics_args['M_2'] = 15\n",
-    "    physics_args['separation'] = 0 # 0 = ignored, use period\n",
-    "    physics_args['orbital_period'] = 4530.0\n",
-    "\n",
-    "    arg_string = create_arg_string(physics_args)\n",
-    "    arg_string = 'binary_c {arg_string}'.format(arg_string=arg_string)\n",
-    "\n",
-    "    buffer = \"\"\n",
-    "\n",
-    "    output = binary_c.run_binary(arg_string)\n",
-    "\n",
-    "    # Make some \n",
-    "    results = {}\n",
-    "    time_arr = []\n",
-    "    mass_arr = []\n",
-    "    mass_2_arr = []\n",
-    "\n",
-    "    # split output on newlines\n",
-    "    for line in output.split('\\n'):\n",
-    "        # Skip any blank lines\n",
-    "        if not line=='':\n",
-    "            split_line = line.split()\n",
-    "            header = split_line[0]\n",
-    "            value_array = split_line[1:]\n",
-    "\n",
-    "            # Use parse data here:\n",
-    "            if header=='TESTLOG':\n",
-    "                # Add values to lists\n",
-    "                time_arr.append(float(value_array[0]))\n",
-    "                mass_arr.append(float(value_array[1]))\n",
-    "                mass_2_arr.append(float(value_array[4]))\n",
-    "\n",
-    "    # Save in results dir\n",
-    "    results['time'] = time_arr\n",
-    "    results['mass'] = mass_arr\n",
-    "    results['mass2'] = mass_2_arr\n",
-    "\n",
-    "    return results\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 13,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "results = example_with_loading_default_args()\n",
-    "df = pd.DataFrame.from_dict(results)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 27,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAJQCAYAAADR8SOKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3debhld13n+/d3D+fUmMpUZA5hDESGgGUAQW4QBAI04AASJ7TRyGRjC3SrbYu3fW5fW6+2cFFi7KQDtg0KCI0ShrQXLtAyVTCQMCYCMRWSVGWspFLDGb79x96n6uTknKo6e1q/88v79Tz72Xuv6XyL9ZzDJ9/f+q0VmYkkSZLK1Gq6AEmSJK3MsCZJklQww5okSVLBDGuSJEkFM6xJkiQVrNN0AeNy4okn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pwNfWrJsN3BjRDyOXoftr5asvxg4B3gz9++cbQQ+n5lPzMzPZOY8cD3wxKP5B0t6cPC/3iQ9WHwiM+8B7omIu4G/7S+/BnhCRGwCfhB4b0Qs7DO9zHFOAXYts/w99ILa84BnA7+wsCIz5yPiz4BtmXn7on3mgPcvOc5O4FTgqlX82yRVzLAm6cFi/6LP84u+z9P7W9gC7srMc49wnL3AlmWW/x3wB8D2zNy9KPAt/pnzS5bty8y5JcvW9X+GJAEOg0qqxz3A5kF3zszdwHci4mUA0bPccOTXgUcuXZiZ9wH/lt4Q6zAeDVw75DEkVcSwJqkK/eHF/xUR10bEHwx4mJ8GXtW/4P+r9CcNLPEp4EmxTOssM9+TmUuvZztqEXESsDczbxn0GJLqE5nZdA2StKZExFuBv83M/zni4/5rYHdmXjrK40pa2+ysSdLq/UdgwxiOexfwzjEcV9IaZmdNkiSpYHbWJEmSCmZYkyRJKphhTZIkqWCGNUmSpIIZ1iRJkgr2vwHMVO+fqihHWQAAAABJRU5ErkJggg==\n",
-      "text/plain": [
-       "<Figure size 720x720 with 1 Axes>"
-      ]
-     },
-     "metadata": {
-      "needs_background": "light"
-     },
-     "output_type": "display_data"
-    }
-   ],
-   "source": [
-    "min_time = 1e-1\n",
-    "max_time = 3000\n",
-    "# Plot some stuff\n",
-    "plt.figure(figsize=[10,10])\n",
-    "plt.plot(df[(df.time>min_time) & (df.time<max_time)]['time'], df[(df.time>min_time) & (df.time<max_time)]['mass'])\n",
-    "plt.plot(df[(df.time>min_time) & (df.time<max_time)]['time'], df[(df.time>min_time) & (df.time<max_time)]['mass2'])\n",
-    "plt.xscale('log')\n",
-    "plt.ylabel(r'Mass $M_{\\odot}$')\n",
-    "plt.xlabel('time (MYr)')\n",
-    "plt.show()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3",
-   "language": "python",
-   "name": "python3"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 3
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython3",
-   "version": "3.6.4"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/examples/example_run_binary_with_custom_logging.py b/examples/example_run_binary_with_custom_logging.py
new file mode 100644
index 0000000000000000000000000000000000000000..02336da32feb64a334bcea5efcf601e9c635b5ee
--- /dev/null
+++ b/examples/example_run_binary_with_custom_logging.py
@@ -0,0 +1,32 @@
+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, temp_custom_logging_dir, create_and_load_logging_function
+import binary_c
+
+# generate logging lines
+logging_line = autogen_C_logging_code(
+    {
+        'MY_STELLAR_DATA': ['model.time', 'star[0].mass'], 
+        'my_sss2': ['model.time', 'star[1].mass']
+    }
+)
+
+# Generate code around logging lines
+custom_logging_code = binary_c_log_code(logging_line)
+
+# Generate library and get memaddr
+func_memaddr = create_and_load_logging_function(custom_logging_code)
+
+# 
+m1 = 15.0 # Msun
+m2 = 14.0 # Msun
+separation = 0 # 0 = ignored, use period
+orbital_period = 4530.0 # days
+eccentricity = 0.0
+metallicity = 0.02
+max_evolution_time = 15000
+argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}".format(m1,m2,separation,orbital_period,eccentricity,metallicity,max_evolution_time)
+output = binary_c.run_binary_custom_logging(argstring, func_memaddr)
+print(output)
\ No newline at end of file
diff --git a/examples/examples_run_binary.py b/examples/examples_run_binary.py
new file mode 100644
index 0000000000000000000000000000000000000000..47e84f65e33feff3ec44e3b1c1a54675e21b6aff
--- /dev/null
+++ b/examples/examples_run_binary.py
@@ -0,0 +1,143 @@
+#!/usr/bin/python3
+import os
+import sys
+
+import binary_c
+
+from binaryc_python_utils.functions import run_system, parse_output
+from binaryc_python_utils.custom_logging_functions import autogen_C_logging_code, binary_c_log_code
+
+"""
+Very basic scripts to run a binary system and print the output.
+
+Use these as inspiration/base
+"""
+
+def run_example_binary():
+    """
+    Function to run a binary system. Very basic approach which directly adresses the run_binary(..) python-c wrapper function. 
+
+    """
+
+    m1 = 15.0 # Msun
+    m2 = 14.0 # Msun
+    separation = 0 # 0 = ignored, use period
+    orbital_period = 4530.0 # days
+    eccentricity = 0.0
+    metallicity = 0.02
+    max_evolution_time = 15000 # Myr. You need to include this argument.
+
+    # 
+    argstring = "binary_c M_1 {m1} M_2 {m2} separation {separation} orbital_period {orbital_period} \
+        eccentricity {eccentricity} metallicity {metallicity} \
+        max_evolution_time {max_evolution_time}".format(m1=m1, m2=m2, separation=separation, orbital_period=orbital_period, eccentricity=eccentricity, metallicity=metallicity, max_evolution_time=max_evolution_time)
+    output = binary_c.run_binary(argstring)
+    print (output)
+
+# run_example_binary()
+
+def run_example_binary_with_run_system():
+    """
+    This function serves as an example on the function run_system and parse_output. 
+    There is more functionality with this method and several tasks are done behind the scene.
+
+    Requires pandas, numpy to run.
+
+    run_system: mostly just makes passing arguments to the function easier. It also loads all the necessary defaults in the background
+    parse_output: Takes the raw output of binary_c and selects those lines that start with the given header. 
+    Note, if you dont use the custom_logging functionality binary_c should be configured to have output that starts with that given header
+    """
+
+    import pandas as pd
+    import numpy as np
+
+    # Run system. all arguments can be given as optional arguments.
+    output = run_system(M_1=10, M_2=20, separation=0, orbital_period=100000000000)
+
+    # Catch results that start with a given header. (Mind that binary_c has to be configured to print them if your not using a custom logging function)
+    result_example_header = parse_output(output, 'example_header')
+
+    #### Now do whatever you want with it: 
+    # Put it in numpy arrays
+    #t_res = np.asarray(result_example_header['t'], dtype=np.float64, order='C')
+    #m_res = np.asarray(result_example_header['mass'], dtype=np.float64, order='C')
+
+    # Cast the data into a dataframe. 
+    df = pd.DataFrame.from_dict(result_example_header, dtype=np.float64)
+
+    # print(df) 
+    # sliced_df = df[df.t < 1000] # Cut off late parts of evolution
+    # print(sliced_df[["t","m1"]])
+
+    # Some routine to plot.
+
+# run_example_binary_with_run_system()
+
+
+def run_example_binary_with_custom_logging():
+    """
+    Function that will use a automatically generated piece of logging code. Compile it, load it 
+    into memory and run a binary system. See run_system on how several things are done in the background here.
+    """
+
+    import pandas as pd
+    import numpy as np
+
+    # generate logging lines. Here you can choose whatever you want to have logged, and with what header
+    # this generates working print statements
+    logging_line = autogen_C_logging_code(
+        {
+            'MY_STELLAR_DATA': ['model.time', 'star[0].mass'], 
+        }
+    )
+    # OR
+    # You can also decide to `write` your own logging_line, which allows you to write a more complex logging statement with conditionals.
+    logging_line = 'Printf("MY_STELLAR_DATA time=%g mass=%g\\n", stardata->model.time, stardata->star[0].mass)'
+
+    # Generate entire shared lib code around logging lines
+    custom_logging_code = binary_c_log_code(logging_line)
+
+    # Run system. all arguments can be given as optional arguments. the custom_logging_code is one of them and will be processed automatically.
+    output = run_system(M_1=1, metallicity=0.002, M_2=0.1, separation=0, orbital_period=100000000000, custom_logging_code=custom_logging_code)
+
+    # Catch results that start with a given header. (Mind that binary_c has to be configured to print them if your not using a custom logging function)
+    # DOESNT WORK YET if you have the line autogenerated.
+    result_example_header = parse_output(output, 'MY_STELLAR_DATA')
+
+    # Cast the data into a dataframe. 
+    df = pd.DataFrame.from_dict(result_example_header, dtype=np.float64)
+
+    # Do whatever you like with the dataframe.
+    print(df)
+
+# run_example_binary_with_custom_logging()
+
+def run_example_binary_with_writing_logfile():
+    """
+    Same as above but when giving the log_filename argument the log filename will be written
+    """
+
+    import pandas as pd
+    import numpy as np
+
+    # Run system. all arguments can be given as optional arguments.
+    output = run_system(M_1=10, M_2=20, separation=0, orbital_period=100000000000, log_filename=os.getcwd()+'/test_log.txt')
+
+    # Catch results that start with a given header. (Mind that binary_c has to be configured to print them if your not using a custom logging function)
+    result_example_header = parse_output(output, 'example_header')
+
+    #### Now do whatever you want with it: 
+    # Put it in numpy arrays
+    #t_res = np.asarray(result_example_header['t'], dtype=np.float64, order='C')
+    #m_res = np.asarray(result_example_header['mass'], dtype=np.float64, order='C')
+
+    # Cast the data into a dataframe. 
+    df = pd.DataFrame.from_dict(result_example_header, dtype=np.float64)
+
+    # print(df) 
+    # sliced_df = df[df.t < 1000] # Cut off late parts of evolution
+    # print(sliced_df[["t","m1"]])
+
+    # Some routine to plot.
+
+# run_example_binary_with_writing_logfile()
\ No newline at end of file
diff --git a/examples/log_filename_test.py b/examples/log_filename_test.py
deleted file mode 100644
index 80d244bac185b7c6730fbba7428a74b335db1626..0000000000000000000000000000000000000000
--- a/examples/log_filename_test.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import os, sys
-import matplotlib.pyplot as plt
-
-# Append root dir of this project to include functionality
-sys.path.append(os.path.dirname(os.getcwd()))
-import binary_c
-from utils.defaults import physics_defaults
-from utils.functions import create_arg_string
-
-"""
-This script is intended to have the logfile of a binary system being outputted to a given directory so that we can use that logfile for other purposes
-Like plotting/visualizing the general evolution of that system using e.g. Mirons script
-"""
-
-def example_with_loading_default_args():
-    """
-    Example function loading the default physics args for a binary_c system. Got
-    it from the binary_grid2 perl module
-
-    This function works if binary_c is set to log something every timestep so that we can plot the evolution of a system
-    """
-
-    # Load args
-    physics_args = physics_defaults.copy()
-
-    # Manually set M_1, M_2, orbital_period and separation values:
-    physics_args['M_1'] = 20
-    physics_args['M_2'] = 15
-    physics_args['separation'] = 0 # 0 = ignored, use period
-    physics_args['orbital_period'] = 4530.0
-
-    physics_args['log_filename'] = os.path.join(os.getcwd(), 'test.log')
-    print(physics_args['log_filename'])
-
-    arg_string = create_arg_string(physics_args)
-    arg_string = f'binary_c {arg_string}' 
-
-    buffer = ""
-
-    print(arg_string)
-
-    output = binary_c.run_binary(arg_string)
-example_with_loading_default_args()
\ No newline at end of file
diff --git a/examples/loop_system.py b/examples/loop_system.py
deleted file mode 100644
index 622b9c75c6dce6e63a32a715d235b7861561a824..0000000000000000000000000000000000000000
--- a/examples/loop_system.py
+++ /dev/null
@@ -1,66 +0,0 @@
-import os, sys
-import matplotlib.pyplot as plt
-
-# Append root dir of this project to include functionality
-sys.path.append(os.path.dirname(os.getcwd()))
-import binary_c
-from utils.defaults import physics_defaults
-from utils.functions import create_arg_string
-
-"""
-This script is an example of running a group of binary systems using a loop. For big grids this is not wise, the grid functionality will be built later
-
-I made this script to with the logging of binaryc set to log only one line per system (when a certain requirement is met).
-
-You can either capture the data and print it, or write it to a file
-"""
-
-def run_simple_loop_binary():
-    # Some simple function with a loop
-    # This function assumes a single output line
-
-    m2 = 14.0 # Msun
-    separation = 0 # 0 = ignored, use period
-    orbital_period = 4530.0 # days
-    eccentricity = 0.0
-    metallicity = 0.02
-    max_evolution_time = 15000
-    buffer = ""
-
-    print ("Binary_c grid output:")
-
-    mass_1 = []
-    time = []
-    initial_m1 = []
-
-    # Set up for loop. Beware: this is only a proof of concept example. big grid should not be run in this way. rather one should use a queueing/threading system. 
-    for m1 in range(15, 20): 
-        argstring = f"binary_c M_1 {m1} M_2 {m2} separation {separation} orbital_period {orbital_period} eccentricity {eccentricity} metallicity {metallicity} max_evolution_time {max_evolution_time}"
-        
-        # Get the output string
-        output = binary_c.run_binary(argstring)
-
-        # split output on newlines
-        for line in output.split('\n'):
-            # Example of splitting off certain lines of output
-            if line.startswith('TESTLOG_BINARY_POP'):
-                value_array = line.split()[1:]
-                # print(value_array)
-
-                # Either save the results in arrays or lists
-                mass_1.append(value_array[1])
-                time.append(value_array[0])
-                initial_m1.append(value_array[2])
-
-                # write headers. can be cleaner
-                if not os.path.isfile("test_output.txt"):
-                    with open("test_output.txt", "a") as f:
-                        f.write('time M1 M1_zams\n')
-
-                # Or write them to a file with a file:
-                with open("test_output.txt", "a") as myfile:
-                    myfile.write(' '.join(value_array[:3])+'\n')
-
-    print('mass1:', mass_1)
-    print('zams_mass1:' ,initial_m1)
-    print('time:', time)
\ No newline at end of file
diff --git a/examples/simple_test.py b/examples/simple_test.py
deleted file mode 100644
index 75191f5bcc984c7a8df7430b2d36721ce987e726..0000000000000000000000000000000000000000
--- a/examples/simple_test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python3
-import os
-import sys
-
-# Append root dir of this project to include functionality
-sys.path.append(os.path.dirname(os.getcwd()))
-import binary_c
-
-from utils.defaults import physics_defaults
-from utils.functions import create_arg_string
-
-
-def run_test_binary():
-    m1 = 15.0 # Msun
-    m2 = 14.0 # Msun
-    separation = 0 # 0 = ignored, use period
-    orbital_period = 4530.0 # days
-    eccentricity = 0.0
-    metallicity = 0.02
-    max_evolution_time = 15000
-    buffer = ""
-    # argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}  ".format(m1,m2,separation,orbital_period,eccentricity,metallicity,max_evolution_time)
-    
-    argstring = f"binary_c M_1 {m1} M_2 {m2} separation {separation} orbital_period {orbital_period} eccentricity {eccentricity} metallicity {metallicity} max_evolution_time {max_evolution_time}"
-
-    output = binary_c.run_binary(argstring)
-
-    # print ("Binary_c output:\n\n")
-    print (output)
-
-run_test_binary()
diff --git a/examples/single_system.py b/examples/single_system.py
deleted file mode 100644
index 561a0fd0ee9495cec38900df75cd550086ffd0ae..0000000000000000000000000000000000000000
--- a/examples/single_system.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import os, sys
-
-# Append root dir of this project to include functionality
-sys.path.append(os.path.dirname(os.getcwd()))
-import binary_c
-
-
-"""
-Example script for running a single system. This is a very simple set up.
-For a different way of inputting arg strings:
-
-from utils.defaults import physics_defaults
-from utils.functions import create_arg_string
-
-physics_args = physics_defaults.copy()
-physics_args['orbital_period'] = 4530.0
-
-arg_string = create_arg_string(physics_args)
-arg_string = f'binary_c {arg_string}' 
-
-Other examples can be found using this method
-"""
-
-def run_test_binary():
-    m1 = 15.0 # Msun
-    m2 = 14.0 # Msun
-    separation = 0 # 0 = ignored, use period
-    orbital_period = 4530.0 # days
-    eccentricity = 0.0
-    metallicity = 0.02
-    max_evolution_time = 15000
-    buffer = ""
-    # argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}  ".format(m1,m2,separation,orbital_period,eccentricity,metallicity,max_evolution_time)
-    
-    argstring = f"binary_c M_1 {m1} M_2 {m2} separation {separation} orbital_period {orbital_period} eccentricity {eccentricity} metallicity {metallicity} max_evolution_time {max_evolution_time}"
-
-    output = binary_c.run_binary(argstring)
-
-    # print ("Binary_c output:\n\n")
-    print (output)
\ No newline at end of file
diff --git a/make_output.txt b/make_output.txt
deleted file mode 100644
index f5c47eae0d6573ddba2b6445bebce381a1baad45..0000000000000000000000000000000000000000
--- a/make_output.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-gcc -fPIC `/vol/ph/astro_code/dhendriks/binaryc/binary_c/binary_c-config --flags` -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/ -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/API    -c -o binary_c_python_api.o binary_c_python_api.c
-gcc -DBINARY_C=/vol/ph/astro_code/dhendriks/binaryc/binary_c -fPIC `/vol/ph/astro_code/dhendriks/binaryc/binary_c/binary_c-config --flags` -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/ -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/API   binary_c_python_api.c -c  -lbinary_c `/vol/ph/astro_code/dhendriks/binaryc/binary_c/binary_c-config --libs`  
-gcc -DBINARY_C=/vol/ph/astro_code/dhendriks/binaryc/binary_c -shared -o libbinary_c_api.so binary_c_python_api.o
-python3 setup.py build_ext --inplace 
-running build_ext
-building 'binary_c' extension
-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DALIGNSIZE=16 -DCPUFREQ=3600 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__HAVE_PERF_EVENTS__ -DGIT_REVISION=1:20190808:97d7029f -DGIT_URL=gitlab@gitlab.eps.surrey.ac.uk:ri0005/binary_c.git -DGIT_BRANCH=branch_david -D__HAVE_AVX__ -D__HAVE_DRAND48__ -D__HAVE_GSL__ -DUSE_GSL -D__HAVE_LIBBSD__ -D__HAVE_MALLOC_H__ -D__HAVE_PKG_CONFIG__ -D__HAVE_VALGRIND__ -D__SHOW_STARDATA__ -DBINARY_C_API_H=/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/API/binary_c_API.h -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src -I/vol/ph/astro_code/dhendriks/binaryc/binary_c/src/API -I/vol/ph/astro_code/dhendriks/binaryc/binary_c -I/usr/include -I/user/HS128/dh00601/gsl/include -I/user/HS128/dh00601/.pyenv/versions/binaryc_py3.6.4/include -I/user/HS128/dh00601/.pyenv/versions/3.6.4/include/python3.6m -c binary_c_python.c -o build/temp.linux-x86_64-3.6/binary_c_python.o
-gcc -pthread -shared -L/user/HS128/dh00601/.pyenv/versions/3.6.4/lib -L/user/HS128/dh00601/.pyenv/versions/3.6.4/lib build/temp.linux-x86_64-3.6/binary_c_python.o -L/vol/ph/astro_code/dhendriks/binaryc/binary_c/src -L./ -L-L/vol/ph/astro_code/dhendriks/binaryc/binary_c -L-L/user/HS128/dh00601/gsl/lib -Wl,--enable-new-dtags,-R/vol/ph/astro_code/dhendriks/binaryc/binary_c/src -Wl,--enable-new-dtags,-R./ -Wl,--enable-new-dtags,-R-L/vol/ph/astro_code/dhendriks/binaryc/binary_c -Wl,--enable-new-dtags,-R-L/user/HS128/dh00601/gsl/lib -lbinary_c -lgsl -lgslcblas -lm -lbsd -lc -lm -ldl -lbinary_c_api -o /vol/ph/astro_code/dhendriks/binaryc/binary_c-python/binary_c.cpython-36m-x86_64-linux-gnu.so
diff --git a/old_solution/binary_c_api.c b/old_solution/binary_c_api.c
deleted file mode 100644
index afd31aa6473fab49237764cce1211885802f42bd..0000000000000000000000000000000000000000
--- a/old_solution/binary_c_api.c
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "binary_c_python.h"
-//#include "binary_c_api.h"
-#include "binary_c_API.h"
-#include "binary_c_API_prototypes.h"
-#include <time.h>
-#include <sys/timeb.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-
-/*
- * apitest
- *
- * Short test programme to throw random binary systems at binary_c's
- * library via its API.
- *
- * Note that it looks more complicated than it is because I have included
- * code to capture binary_c's stdout stream and output it here.
- *
- * This code sends output to stderr : you should use apitest.sh to run it
- * and hence force output to your terminal's stdout.
- *
- * Output lines:
- *
- * APITEST ....  is information about what this code is doing.
- * STATUS  ....  is information about the binary system.
- * BINARY_C .... is output from binary_c (see iterate_logging.c etc.)
- *               which would have gone to stdout
- *
- * If you define the NO_OUTPUT macro, there will be no output except
- * the memory allocation and test system information. This is useful for speed tests,
- * but note that you may end up in a race condition where the pipe which replaces
- * stdout's buffer fills and hence the code stops.
- *
- * Note:
- * I have tested this with gcc 4.7.2 (Ubuntu 12.10) only.
- */
-
-
-// #define _CAPTURE
-#ifdef _CAPTURE
-static void show_stdout(void);
-static void capture_stdout(void);
-#endif
-
-
-/* global variables */
-int out_pipe[2];
-int stdoutwas;
-
-int main(int argc,
-         char * argv[])
-{
-    char * argstring = MALLOC(sizeof(char) * (size_t)STRING_LENGTH);
-    snprintf(argstring,
-             STRING_LENGTH,
-             "binary_c M_1 %g M_2 %g separation %g orbital_period %g metallicity %g max_evolution_time %g\n",
-             20.0,
-             15.0,
-             0.0,
-             3.0,
-             0.02,
-             15000.0);
-
-    char * buffer ;
-    size_t nbytes;
-    int out = run_binary(argstring,
-                     &buffer,
-                     &nbytes);
-
-    printf("output (binary_c returned %d)\n%s\n",out,buffer);
-
-    free(buffer);
-    
-    return out;
-}
-
-
-int run_binary(char * argstring,
-               char ** buffer,
-               size_t * nbytes)
-{
-    /* memory for N binary systems */
-    struct libbinary_c_stardata_t *stardata;
-    struct libbinary_c_store_t * store = NULL;
-
-    printf("argstring : %s\n",argstring);
-    fflush(stdout);
-
-    stardata = NULL;
-    binary_c_new_system(&stardata,
-                        NULL,
-                        NULL,
-                        &store,
-                        &argstring,
-                        -1);
-    snprintf(stardata->preferences->log_filename,
-             STRING_LENGTH-1,
-             "%s",
-             "/dev/null");
-    snprintf(stardata->preferences->api_log_filename_prefix,
-             STRING_LENGTH-1,
-             "%s",
-             "/dev/null");
-    stardata->preferences->internal_buffering = 2;
-    stardata->preferences->internal_buffering_compression = 0;
-    stardata->preferences->batchmode = BATCHMODE_LIBRARY;
-
-    binary_c_evolve_for_dt(stardata,
-                           stardata->model.max_evolution_time);
-
-    /*
-     * Save the buffer pointer
-     */
-    binary_c_buffer_info(stardata,&buffer,nbytes);
-
-    /*
-     * And free everything else
-     */    
-    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE);
-    binary_c_free_store_contents(store);
-    
-    return 0;
-}
-
-int return_arglines(char ** buffer,
-               size_t * nbytes)
-{
-    /* memory for N binary systems */
-    struct libbinary_c_stardata_t *stardata;
-    struct libbinary_c_store_t * store = NULL;
-
-    /* make new stardata */
-    stardata = NULL;
-    char * empty_str = "";
-    binary_c_new_system(&stardata,
-                        NULL,
-                        NULL,
-                        &store,
-                        &empty_str,
-                        -1);
-
-    /* disable logging */
-    snprintf(stardata->preferences->log_filename,
-             STRING_LENGTH-1,
-             "%s",
-             "/dev/null");
-    snprintf(stardata->preferences->api_log_filename_prefix,
-             STRING_LENGTH-1,
-             "%s",
-             "/dev/null");
-
-    /* output to strings */
-    stardata->preferences->internal_buffering = 2;
-    stardata->preferences->internal_buffering_compression = 0;
-    stardata->preferences->batchmode = BATCHMODE_LIBRARY;
-
-    /* List available arguments */
-    binary_c_list_args(stardata);
-
-    /* get buffer pointer */
-    binary_c_buffer_info(stardata,buffer,nbytes);
-
-    /* set raw_buffer_size = -1 to prevent it being freed */
-    stardata->tmpstore->raw_buffer_size = -1;
-    
-    /* free stardata (except the buffer) */
-    binary_c_free_memory(&stardata,TRUE,TRUE,FALSE);
-    binary_c_free_store_contents(store);
-    return 0;
-}
\ No newline at end of file
diff --git a/old_solution/binary_c_api.h b/old_solution/binary_c_api.h
deleted file mode 100644
index 950f505aac9f6df0ba55c152c7fc80788f3d8211..0000000000000000000000000000000000000000
--- a/old_solution/binary_c_api.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-#ifndef BINARY_C_PYTHON_API_H
-#define BINARY_C_PYTHON_API_H
-
-/* local function prototypes */
-static void APIprintf(char * format,...);
-
-int run_binary(char * argstring,
-               char ** buffer,
-               size_t * nbytes);
-
-int return_arglines(char ** buffer,
-               size_t * nbytes);
-
-/* C macros */
-#define BINARY_C_APITEST_VERSION 0.1
-#define APIprint(...) APIprintf(__VA_ARGS__);
-#define NO_OUTPUT
-
-#endif // BINARY_C_PYTHON_API_H
diff --git a/old_solution/binary_c_api_python.h b/old_solution/binary_c_api_python.h
deleted file mode 100644
index 950f505aac9f6df0ba55c152c7fc80788f3d8211..0000000000000000000000000000000000000000
--- a/old_solution/binary_c_api_python.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-#ifndef BINARY_C_PYTHON_API_H
-#define BINARY_C_PYTHON_API_H
-
-/* local function prototypes */
-static void APIprintf(char * format,...);
-
-int run_binary(char * argstring,
-               char ** buffer,
-               size_t * nbytes);
-
-int return_arglines(char ** buffer,
-               size_t * nbytes);
-
-/* C macros */
-#define BINARY_C_APITEST_VERSION 0.1
-#define APIprint(...) APIprintf(__VA_ARGS__);
-#define NO_OUTPUT
-
-#endif // BINARY_C_PYTHON_API_H
diff --git a/old_solution/compile_script.txt b/old_solution/compile_script.txt
deleted file mode 100644
index db54dea283afd4f9e9c5c5ec801d0498c51021e2..0000000000000000000000000000000000000000
--- a/old_solution/compile_script.txt
+++ /dev/null
@@ -1,61 +0,0 @@
-Jeff's instructions
-
-please see README.md instead!
-
-
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-------------------------------------------------------------
-
-
-
-
-
-----
-
-First, we need to compile binary_c_api.c into a shared library. We can do this by either the short way
-
-make all
-
-or the long way
-
-gcc binary_c_api.c -c -lbinary_c -lm -lc -fpic
-gcc -shared -o libbinary_c_api.so binary_c_api.o
-
-####
-
-export BINARY_C=...
-export LD_LIBRARY_PATY=$BINARY_C/src
-
-gcc `$BINARY_C/binary_c-config --flags` binary_c_api.c -c 
-
-
-####
-
-Next, we need to make sure that the current directory (that containing libbinary_c_api.so) is included in $LD_LIBRARY_PATH
-export LD_LIBRARY_PATH=....
-
-
-Next, we compile the python setup.py script:
-python setup.py build_ext --inplace
-
-Within python, you should be able to now run:
-python python_API_test.py
-
-
-Or access the python functions within an ipython notebook:
-import binary_c
-binary_c.function_name()
-
-
-To remake, first, start by running
-make clean
-
diff --git a/setup.py b/setup.py
index 0969ba532482209705f3a60fe43ad315dc664c22..550b3626203bd91a59662436ef55de60283b61f2 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ import sys
 binary_c_config = os.environ['BINARY_C']+'/binary_c-config'
 
 binary_c_incdirs = subprocess.run([binary_c_config,'incdirs_list'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
-binary_c_libdirs = subprocess.run([binary_c_config,'libdirs'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
+binary_c_libdirs = subprocess.run([binary_c_config,'libdirs_list'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
 binary_c_cflags =  subprocess.run([binary_c_config,'cflags'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
 binary_c_libs = subprocess.run([binary_c_config,'libs_list'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
 
@@ -18,6 +18,7 @@ binary_c_define_macros = []
 defines = subprocess.run([binary_c_config,'define_macros'],stdout=subprocess.PIPE).stdout.decode('utf-8').split()
 lone = re.compile('^-D(.+)$')
 partner = re.compile('^-D(.+)=(.+)$')
+
 for x in defines:
     y = partner.match(x)
     if(y):
@@ -34,15 +35,15 @@ setup(
     name='binary_c',
     version='1.0',
     description='This is a python API for binary_c by Rob Izzard and collaborators',
-    author='Jeff Andrews and Robert Izzard',
-    author_email='andrews@physics.uoc.gr and r.izzard@surrey.ac.uk and rob.izzard@gmail.com',
+    author='Jeff Andrews and Robert Izzard and David Hendriks',
+    author_email='andrews@physics.uoc.gr and r.izzard@surrey.ac.uk and rob.izzard@gmail.com and dhendriks93@gmail.com',
 license='',
     ext_modules=[Extension("binary_c",
                            ["binary_c_python.c"],
-                           libraries = ['binary_c']+binary_c_libs+['binary_c_api'],
-                           include_dirs = [os.environ['BINARY_C']+'/src',os.environ['BINARY_C']+'/src/API']+binary_c_incdirs,
-                           library_dirs = [os.environ['BINARY_C']+'/src', './'] + binary_c_libdirs,
-                           runtime_library_dirs = [os.environ['BINARY_C']+'/src', './']+binary_c_libdirs,
+                           libraries = ['binary_c'] + binary_c_libs + ['binary_c_api'],
+                           include_dirs = [os.environ['BINARY_C'] + '/src', os.environ['BINARY_C'] + '/src/API'] + binary_c_incdirs,
+                           library_dirs = [os.environ['BINARY_C'] + '/src', './'] + binary_c_libdirs,
+                           runtime_library_dirs = [os.environ['BINARY_C']+'/src', './'] + binary_c_libdirs,
                            define_macros = [] + binary_c_define_macros,
                            extra_objects = [],
                            extra_compile_args = [],
diff --git a/examples/__init__.py b/testing_examples/__init__.py
similarity index 100%
rename from examples/__init__.py
rename to testing_examples/__init__.py
diff --git a/examples/example_notebook.ipynb b/testing_examples/example_notebook.ipynb
similarity index 100%
rename from examples/example_notebook.ipynb
rename to testing_examples/example_notebook.ipynb
diff --git a/examples/full_evolution_with_plot.py b/testing_examples/full_evolution_with_plot.py
similarity index 100%
rename from examples/full_evolution_with_plot.py
rename to testing_examples/full_evolution_with_plot.py
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_david/.ipynb_checkpoints/test_noteboo-checkpoint.ipynb b/tests_and_snippets/.ipynb_checkpoints/test_noteboo-checkpoint.ipynb
similarity index 100%
rename from tests_david/.ipynb_checkpoints/test_noteboo-checkpoint.ipynb
rename to tests_and_snippets/.ipynb_checkpoints/test_noteboo-checkpoint.ipynb
diff --git a/snippets/arg_test.py b/tests_and_snippets/snippets/arg_test.py
similarity index 100%
rename from snippets/arg_test.py
rename to tests_and_snippets/snippets/arg_test.py
diff --git a/snippets/d.py b/tests_and_snippets/snippets/d.py
similarity index 100%
rename from snippets/d.py
rename to tests_and_snippets/snippets/d.py
diff --git a/snippets/mp2.py b/tests_and_snippets/snippets/mp2.py
similarity index 100%
rename from snippets/mp2.py
rename to tests_and_snippets/snippets/mp2.py
diff --git a/snippets/mp3.py b/tests_and_snippets/snippets/mp3.py
similarity index 100%
rename from snippets/mp3.py
rename to tests_and_snippets/snippets/mp3.py
diff --git a/snippets/mp3_pool.py b/tests_and_snippets/snippets/mp3_pool.py
similarity index 100%
rename from snippets/mp3_pool.py
rename to tests_and_snippets/snippets/mp3_pool.py
diff --git a/snippets/multiprocessing_test.py b/tests_and_snippets/snippets/multiprocessing_test.py
similarity index 100%
rename from snippets/multiprocessing_test.py
rename to tests_and_snippets/snippets/multiprocessing_test.py
diff --git a/tests_david/testing_automatic_log_readout.py b/tests_and_snippets/testing_automatic_log_readout.py
similarity index 100%
rename from tests_david/testing_automatic_log_readout.py
rename to tests_and_snippets/testing_automatic_log_readout.py
diff --git a/tests_david/test b/tests_david/test
deleted file mode 100644
index 45cb036ed3509bb04ee1070aa75e326199694ea6..0000000000000000000000000000000000000000
--- a/tests_david/test
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/python3
-
-import binary_c
-
-############################################################
-# Test script to run a binary using the binary_c Python
-# module.
-############################################################
-
-def run_test_binary():
-    m1 = 15.0 # Msun
-    m2 = 14.0 # Msun
-    separation = 0 # 0 = ignored, use period
-    orbital_period = 4530.0 # days
-    eccentricity = 0.0
-    metallicity = 0.02
-    max_evolution_time = 15000
-    buffer = ""
-    argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}  ".format(m1,m2,separation,orbital_period,eccentricity,metallicity,max_evolution_time)
-        
-    output = binary_c.run_binary(argstring)
-
-    print ("\n\nBinary_c output:\n\n")
-    print (output)
-
-
-
-binary_star=binary_c.new_system()
-
-print(dir(binary_c))
-# print(binary_star)
-run_test_binary()
-ding = binary_c.return_arglines()
-print(ding)
\ No newline at end of file
diff --git a/tests_david/test_david.py b/tests_david/test_david.py
deleted file mode 100644
index eff9b19fd7181ea01ced3df50a9478358b6684a7..0000000000000000000000000000000000000000
--- a/tests_david/test_david.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/python3
-import os
-import binary_c
-import matplotlib.pyplot as plt
-
-from binaryc_python_utils.defaults import physics_defaults
-
-############################################################
-# Test script to run a binary using the binary_c Python
-# module.
-############################################################
-
-
-
-print(binary_c)
-
-
-# print("Current binary_c object class functions: ")
-# print(dir(binary_c))
-
-# print("Current binary_c.new_system object class functions: ")
-# print(dir(binary_c.new_system()))
-## WHat is the use of new_system?
-
-# print("Current binary_c.run_binary object class functions: ")
-# print(dir(binary_c.run_binary()))
-
-# binary_star=binary_c.new_system()
-# print(binary_star)
-# print(dir(binary_star))
-
-# Test single system
-# run_test_binary()
-
-# Test grid-like
-# run_simple_loop_binary()
\ No newline at end of file