Replace accesses to `sched_active_thread`, `sched_active_pid`, and `sched_threads` with `thread_get_active()`, `thread_get_active_pid()`, and `thread_get_unchecked()` where sensible.