Simplify some code by changing single-scope properties to local variables