move most of the telemetry stuff to telemetry.c