merge and clean up

add GetAVerageSleepTime function