build-sys: fix rule for generating undefined list
Remove dead code and unexport some calls

"make check-api-unused" informs us about code that is not used anymore
or that is exported but only used internally. Fix these all over the
place.