File metadata caching and major refactoring.