adds some utility code I used in the past

This code isn't used anywhere in TDL but I used it to fix
an issue we had this summer and am just commiting it so we
have access to it if its ever useful again.