Fixed bug with auto-detect after refactoring