Fixed issue where C implementation would segfault - we now have a memory safe FORTRAN and C implementation