Refactored clean_chunks method.