Remove unnecessary cast. Fix virtual format checking