Implement separate thread for networks

Also fix math