tidied up ntp code