Small cleanups and fixes

Here is just a few small cleanups and fixes including:

- Avoiding comparison of `signed` and `unsigned` integer data types
- Avoiding comparison of `double` data types for equality (`!=` and `==`)
- Eliminating dead code path (comparing an `unsigned int` with `-1`) and moving necessary checks to the caller function