Added comments and refactored SetGainMode to bool input.