Refactoring and cleanups

- Moving Scope code to its proper place.
- Making one canonical snowscript_to_php() function.
- Cleaning up some stale code.