fixed some bugs that show up on sparse data