Refactor plugin functions into class methods