rewrote core trace code