moved figure definition into the diagram; places captions with the diagram