Optimizing collision detection and resolution between shapes

Hi all,

I am working on a sketch with falling rectangles and circles that collide with each other, the left and right walls, and ground.


The collision detection seems mostly resolved, however when shapes do overlap, whether it be when they are added to the sketch in an already overlapping position, or are pushed together later when there are many colliding shapes, sometimes it takes a few seconds before the collision is resolved. Does this have to do with lag or with collision detection and resolution being carried out of the circle and rectangle classes instead of in a class of its own?

I would greatly appreciate any help!!

All best,