Some code rework. Made progress with perturbation algorithm.