Fixed unsigned integer underflow issue.

Commit d4198eb473440caa378dea2533c7f0f3c3bdac99 fixed the first issue from Volker's bug report (#2), and commit f571d461e3bb019f3269fc06eb155180bcc9d18c fixed the second issue.

This pull request closes #2.