further implementation of the api routines; work in progress: compiles but does not yet work as intended.