porting quirks the third
also making regex more resilient re: bad quirks