Use self:: prefix when referring to flags module
Move FFI code into its own module