Removed useless logging statements.
Reorganized code.