code cleanup and averaging sensor readings to mitigate sensor noise.