FFI Changes

These commits should make it more possible to use stats.c in other languages.