Fix signedness and handle optional variable better (#4085)
Merge pull request #4086 from dschwen/dbgwarn_4085

Fix signedness and handle optional variable better