use Stack instead of BatDynArray for diagnostics