Implement faster sha1 and cleanup code structure