Major cleanup/rewrite of trace visualization script