Fixes issue #667

See #667 for description of the problem