A much better, slimmer d version.

Also more modular file structure.