Detecting and Preventing Type Flaws: a Control Flow Analysis with tags