Big refactoring to sort out file/category structure.