Commit 3 - mostly working.
Commit 4 - many fixups