type fixes and unnecessary variable removal