Core: refactor plugin activation (#686).

See #686.