Improve cleanup helper script

(based on commit 3b4c1f6)

Signed-off-by: Xfurry <xfurry@scriptdev2.com>