Rewrite plugin from scratch