Continue to overhaul the int/long int, index number and sscanf handling.

- Replace sscanf() with strtol() almost everywhere. Better error
  checking for me, and no different behaviors on Linux/*BSD.
- Try to use long int for indices, and variables that correspond to indices across the source.
- Some variable renaming.
- More range checking when dealing with user input indices.