Improved sparse getindex

Now faster and uses less memory in most common cases.