Now use ArrayArithmetic functions

Also reformatted some code