optimizations in sparse building and slicing