Added sparse routines, various fixes.