Update from PR #212 by @jbcrestot