Clean up a bit, take all the problem-specific logic out to their own files.