code changed to fit new RPC apply and cycle mechanism.