fixed a serious hash code bug and lots of performance tweaks