Use Stream API in place of foreach loops.

This is IDEA's automatic inspection, so stuff may be a bit wonky.