qa/1196: fix botches in previous commit
qa/1196: fix botches in previous commit

Cleanup logic is complicated, but was wrong.

adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp