Complete support for Globals. Fix various bugs