add hash function, other fixes/improvements