Refactor filetype handlers into separate packages