@jonas I had a similar problem not quite exceeding the limit. One item you can do is move the strings to Flash.
<pgmspace.h> there is the definition of PSTR which will place the literal in flash
the patternname, which we normaly just use strcpy, we need to use strcpy_P.
strcpy_P states the string will come from Flashmemory and copy it into SRAM space. ...