refactor sha1 stuff