rewrote ping algorithm

also miscellaneous changes