Cleaned up filetype handling