File reorganization and some comments.

process_work and thread_work were very similar, conceptually,
so they've been rolled into the same file.