Added support for multiple diagrams.