Added Scope.extends and fixed some bugs