Implement assignment.
Some small scope and ast refactorings.