fixing reader/writer bugs