Base code for the sparse stack.