Rewrite plugin in cleaner format, update docs