new Substring class + other stuff

New Substring class with corresponding unit tests; new DistinctWithCount
method; rewritten some other methods; minor fixes.