Add Reader/Writer class. Fix many bugs.