This is terribly ugly (relies on eval + globals for state).