IO edge cases

Fixes #642 
Fixes #647 
Fixes #646