Bj0rnen/total segment count

New implementation of generateSegments that takes a total number of requested segments, rather than segments per token range. Because it rounds everything up (especially useful for handling the size 1 ranges), it often produces a few more segments. But always at least as many as asked for.