clean up gain which was not interpreting upper bits correctly