Refactored plugin interface.

Tested on Android and iOS.