Speedups - take Boost code outside main loop