Fix crashes and folding code

Basic list keys (key fold) seems to work, but fold is not yet working as
it needs the file stats to gather a list of files used by the cask.