Subtle type fixes