Usually when you have a lot of private code like this, it's a good idea to extract it out to a separate class and make the methods public. Also, `run_plugin` is pretty long, can you break it up into a few steps?