to a project that uses an AtMega328PB with a 16MHz external crystal and two 22pF capacitors
That sounds like it is running at 1MHz due to fuse settings.Which core are you using and how did you burn the bootloader . ?
I am not using a bootloader at all, just burning sketches directly to the Atmel chip. I am also using MiniCore.
What has the rest of the project got in the way of decoupling capacitors and power supply?Lack of adequate decoupling can cause oscillations on the supply which can basically screw up the clock.