MIME and file serving refactoring