Add error handling.
Add event system.
Fixed diagram display.