implemented integrity check in internalfile + fixed a bug