Adjust thread count based on network connection and airplane mode.

# Review only please.

There are a few comments in the diff that you should check out.