Added rough but working scoping.