Major re-write of boosting function