rewrote code to avoid expanding sparse matrix directly. algo is faulty (again), but lightning fast! :)