Fix scoping errors