Improved scope handling