May I suggest upping the limit of 30 characters to 70 from:
$title = substr($title, 0, 30);
to
$title = substr($title, 0, 70);
I found 30 chr$ too restrictive. I realise Google can only show 58 chr$ but many of my topics are up to 70.
Hack works great for me. Thanks id242.