Implement the Collector class, move some data structures to util.h and add match function to Session class