Add changes based on @ezequiel's suggestions

* Switched to feature testing, rather than feature detection
* Various fixes to improve code clarity