More consistent API calls, compiles and runs without segfaulting