adding all code additions and calibration from riot