Code refactoring.

Waiting for travis.