organized keep alive code, increased interval to 40sec.