Added support for foreign scalar functions. Also renamed foreign utility functions so as to differentiate between the different types of FFI calls.