Fix a couple of edge cases.

I think I prefer your approach as it seems easier to understand.  These were the only cases that I managed to break it on. :)