type and lookup for var refs implemented