Closes #237, although the fix is inefficient, and could perhaps be improved.