Tweaked hashing algorithm, added destructor for threads so that as threads terminate they are cleaned up