Refinement to code block detection, so last and first lines are handled as well.