Much improved implementation of PSO solver.