Fixed compiler warnings.
Fixed off by one error.