Partial Refactor

Initial refactoring of the calibration code. Less repeating, more
calibrating ftw.