Refactor some codes.
Merge pull request #1357 from namusyaka/refactor-some-codes

Refactor some codes.