Making plugins OTP event handlers.

Review this before pulling.