Improved handling of variables