Refactored string maximum length checks.

Added some string argument checks.

Moved some memory allocation of strings to the stack.
Merge pull request #71 from keithj/devel

String handling improvements