Wrote smoothing function, swept up a bit