fixed writing / sha1 check bugs