Fix limit and offset bugs