General bug fixes.

Hi There,

Here are a few fixes for some bugs that I ran into.

The first two fix an issue where there is a fixme or todo comment without any text, eg:

// TODO

I'm not sure what triggered the second bug, but it was possible for the loop above to exit with $i = -1.

Cheers,
Luke.