Fixed some issues with the reader and writer