Install trigger code for plugin and fix a few bugs.