Reorganized code into separate files.