Refactoring of the cleanup_value module.