Here's an improved version of the second patch. There's no functional difference, but the code is easier to read IMO. Mark