Updates to be easier to read and use better isLocal check.