to use iso_c_bindings and do some minor cleanup