Longest common substring

A few changes to longest common subsequence as well.