Moved FFI functions, constants and structs into their own files, and added documentation.