Type switch code cleanup