Added the diagram drawing stuff.