Fix for signed/unsigned comparisons (by Karthik)

Minor update, originally part of #376

Requesting review by @kgururaj to ensure this works on his configuration.