Close files synchronously.

Seems like it causes some problems otherwise.
Simplify log output to avoid stack issues.
Add a feature to calculate a crc checksum.