Refactor type detection, fix import panel