Complete merge code. Add lattice plots