convert more code to use dense instead of sparse arrays