Refact and add UML diagram.