Consistent variable handling. Improve script robustness.