Simplified Union code. I must've been half-asleep when I wrote it!