Cleaned up the code.
Switch to using std::tr1::unordered_set