Fixed some performance issues with the segment generator, now takes approx 3 seconds to generate