Refactor some variables and slightly change the condition within adjustLocalGain() fn to support a sign agreement of 0.