Refactored plugin API to reduce duplication