Improvements to ftdetect

Not much to say here, the first commit is self-explanatory and the second one has detailed description in the commit message.