Clean up some code and add config file for calibration and usage