Algorithm for adding comments rewritten.