Fixup After and at_exit hooks