refactoring + bugfix in TertiaryFitting