Non-semantic changes.
Improve / reduce flattening logic;

Correct type checking logic in comparator.