Support for diagrams, misc. fixes