Fix typeof/instanceof mixup