Some refactoring. Also, now reads from an additional training-data file.