Revert type detection changes 572f8fa (fix #3993)

This reverts commit 572f8fa74f337c9f2266ab8b8fa01bbaa840d8ea, reversing
changes made to 87a52cfdf77de39182a3da23eb829144a89c06d3.