more work on writer.c. added crc function, fixed bugs.