redo toarray() system; add sparse support