numpy broadcasting instead of for loops

A few inefficiencies fixed, in which for loops were used, when
it was much simpler and more efficient to just use numpy logic
/ broadcasting.