Split remote and master main thread loops into two methods.