Removed a source of quadratic behavior and added some timings.