Added support for offsets and sort ordering