Fix an out of bounds write error. Some more protection when reading in data and finally fix a few type casts warnings.
Fix bug 391 by relaxing the SET /P check.