Exit handlers, better depth sorting
Forgot about todo