Improved union type handling