Fixed double free.
Using static variable for library function pointers now.