Cleaning up and simplifying plugin