tribial: some refactorings