Rearrange things a bit more to allow WM to set callback for IM