Code improvements

Changed indexed loops to the for-each variant