redesign trap entry, and thread context