#17 #19 moved main loops into Client and called them by threads