FIXED: analyse_merge_nodes() was not using realloc when new nodes are added. Causing invalid writes to mem.
FIXED: Skip "invalid" nodes.