merge changes from Cheng into the plugin