Fixed some range calculation errors.

Also added support for user-defined swarm size.