cleanup code
support pass state param
Merge pull request #1 from jasl/master

格式化了一下代码并且增加了调整SCOPE和STATE字段的支持