Improved clear_debs function