Reorganized code.

Reorganized code.