Refactor the detect function to not attach to the global by default
Bump version to 4.0.0