Refactored networking to only use 2 threads at the most, and other small things.