Making some public members into private members. This also introduces a bit more const-correctness, and now uses some range-based for loops. No functional changes intended.