Clean up a couple of for loops