lots of fixes to the file structure