Added a scope builder and changed things.

Some files were moved to an external library. The generated code is now
broken again.