Tried to fix some warning and move check for gold to the beginning so that we don't do anything extra