Finished calibration code. Closes #22