Fix 2396/8828

Fixes issues 2396 and 8828.