Made the gain dependent on the sensor resolution.