Numerous changes to the implementation, use of ffi module etc.