Fix bugs.
Merge pull request #297 from ketch/io_bugfix

Fix bugs.