put scratch directory functionality into c++ class
tidy up - removed code that was deprecated by previous changes
moving file-related methods into appropriate class