replace hash.c; speedup/cleanup from Chris Torek