Added forgotten includes.
Always link against gperftools if they are available.
Abstracted out the obtaining of cluster membership information. Numerous
bug fixes. Added input filtering as per Liang's implementation which
drasticly cuts down the tokens considered for clustering.