Added NTP support and cleaned up median math

Andreas did most of the work here to support NTP measurement results, and also found a bug in how we were calculating median values.  He then moved this logic into the base class so it can be used elsewhere.