More numpy optimization
remove unused avg() function