Apply Dominique patch for issue #320