Code folding fixes