Reworked splitting logic.