I guess this whole back and forth between int and (unsigned int) size_t is necessary as "-1" is treated as a special value. I'm wondering if there isn't a nicer way to do this.