more refactoring
rewrote compactify to use coo_matrix

much faster