Added mildly dodgy logic to parse scope names