MOD slight refactoring and optimization
Merge pull request #1 from daviddengcn/master

Some small changes