Refactored diagram processor a bunch