Add type annotations to avoid some boxing.