fix compile warning (assignment inside if)
fix HasExtension didn't necessarily terminate correctly