Typing: fixed various inferencing bugs