Fix undeclared globals in functions and shorten lines in misc_helpers.lua.
Settings: Sanitize value for multiline terminator tokens
Settings: Fail on invalid sequence and throw exception for LuaSettings