Use less mutable vars and less casts in GenJSExports.