Clean up and comment LCS function