Refactoring to serve files by mime type. @psh