Refactor thread deletion so it can be consistent.
Optimize callback checking.

Since it's checked every resched, it happens a lot.
This could save as much as 1.6% of time.
Always check for more callbacks after running one.
Recover from an interrupt during a callback.
Merge pull request #516 from unknownbrackets/callbacks

Callback fixes