Fix for issue 631. Martin, thanks for the contribution.