Some type fixes and const correctness.