Seperated the math from the index-manipulation code in StripeProxyModel, for clarity and reuse.