correct crc calculation function.
correct database close procedure.