Fix for #810 rebased against 1.2.1

See #810