Code block termination comments and minor restructuring