Builtin/common/misc_helpers: fix undeclared globals in functions. Shorten lines