Allow midi files with >2 voices, some refactoring