Fix for zero length strings.
Various fixes to allow optimizations with VS2012.