Fixes for new scipy version where X.data != X[X.nonzero()]