Lots of fixes to scopes and operations.