Improved sparse checking; added scipy as dependency