A batch of type fixes and var declaration fixes.