Updated for #2091
Test case for #2091
Fix #2091
Misc fixes
Fix invalid reads