Moved some network functions to separate thread