Thanks Eugene Kovalev for the initial patch, Simon Charette for the review, and Chetan Khanna for help.