untested good api-targeted refactor
scripted update of code from master at e9aa30a untested good api-targeted refactor