Steps 1-3 of the expansion algorithm.