Fix trap functions