Final working fix

Finally the correct pattern!
This fix also includes a lot of spaces replaced by tabs and a
optimalised pattern detection