Improve handling of variables