Fix Segfault
Fix Mem Free bug
Added tracing