Bug 1230: WIP - a little more generic solution.