Clean up directory structure, split code into files.