Fix device IndexError on first run with no devices
Set gain to closest value