merge the whole changes to master from refactor

merge the whole changes to master from refactor