Remove dependence on scipy