Reorganized some code.