Added some helper functions to avoid horrible downcasting.
The variable values are now evaluated.