refactor is almost done, just a few clean up!

after a great lot of hard work, the refactor is almost finished!!!
need to clean the code for the patch.
do more test and write a document about the hook framework(or how to use it)