port to Swift (yay self-documentation)

Even though this works, I'm not convinced it's the right move just yet... So leaving it here for now.