A cursory look, I think your suggested workaround should work