Various changes brought in. Patch from Vincent Torri - thanks
Some refactoring to start splitting out file management from UI