cleanup trap code