Re-integrated trap and fixed clean() syntax [ci skip]