Might also want to consider this alternative version:
I have it as a pull request as well, but has not been implemented.