@dahlbyk: I think this logic is correct? (There's an early return above.)