Issue 881. Fixes after code-review.