Some changes to trapping implementation