Fixing issues #922 and #858

Let's hope this one passes.