I adapted this from Vumi's utils module. I can make that change, but perhaps it should be done in Vumi too.