Major rewrite.
Merge branch 'restructuring'