do not unify cast return types, check for equality instead (closes #2125)
keep type stack to avoid infinite recursion while DCEing (closes #2124)