Refactor: scheduler: best practices when cleaning orphans
Rename cleanup_orphans() to clear_failcounts_if_orphaned() for clarity,
add a doxygen block, and improve comments, variable names, log messages, and
formatting. Also, move a check from the caller to the function so it can be
used with g_list_foreach().