Correctly remove previous phases.

Fixes: bug #1189716

Change-Id: I747e7bbcb2dfccf67b32cc04ea68c153e38ea534
Merge "Correctly remove previous phases."