Added diagnostics, and organized a bit.