Remove unnecessary cast.
Properly duplicate StaticScope for proc construction.