Split up ftdetect, added scala syntax and indentation