Coverity cleanup.
Remove dead variables, use bool.
Factor out the DOT generation.
Refactor for information hiding.