Refactor plugins to use new memory management system