Initial implementation of union for both algos.
Refactoring of KMV functions to make union easier to implement.