Refactor to mbaxter plugin