Basic impl.
Refactorings needed for the scm-api branch.
Merge branch 'master' into scm-api