Sped up the Scope class by using a custom Stack object.

The custom stack object stores the first element in the container, which
speeds up the common case for Scope of one-element stacks.

This change speeds up compilation of local laplacian by ~30%