Refactored Trapd.