Cleanups to the living level

This more clearly modularizes the code while avoiding side effects. Most of the diff is from increasing indentation levels and moving DOMImplementation into its own file.

/cc @fhemberger since he's doing work around here.