Fixed wrong variable name
Fixed sigsegv sometimes when running
Fixed a segfault when clicking Show Diagram