Fix type handling problems