move some legacy code in preparation for refactoring (and hopefully fixing) it (nw)