Refactored/modified handling of variables.