Ported IM Invoker for pre 3.0 and beautified code