I don't have time at the moment to move this into a separate class and retest everything afterwards.
I was hoping we can get this merged first (with minimal changes if needed) as it already works well solves the performance issues.