Flatten the fs hierarchy, and make some filenames more precise.
Account for null byte in string length (resolves issue #833)