Gloo: fixes to variable.py

Some backported from Luke's scenegraph branch. Also fixes one
or two additional bugs.