Added spacing and brackets

Added spacing around some loops and if statements. Also added brackets around
all loops and if statements. I find this makes it more readable.