A few local util functions will go along way here (maybe in your next CL)?