Use auto& if possible in for loops. Closes #349.