Add some comments. Modify run_pending_tasks() to return bool.