Minor refactoring of the wm API