improve plugin architecture and fix a potential highlight bug