Several changes to the read() and write() methods

See discussion in #34.