More efficient nested comment algorithm