Cleaning up the sensor code