A fast algorithm to remove proper and homogeneous pairs of cliques (while preserving some graph invariants)