big refactory to this plugin.

Signed-off-by: Daogang Tang <daogangtang@gmail.com>