added global types, some modifications to scoping