Add filetype param.

Also changes cls param name to klass for idomatic reasons.