[Toolkit] Improve GC performance by fixing a couple of possible allocation hotspots