optimize hash function, source code restructure