Fixed sparse bugs; other fixes