Better diagram parsing, lots of improvements