Made code more pythonic by removing use of forloops wherever possible and replacing with functions from modules esp. numpy
Fixed merge conflict