Updates to account for possibly rare cases

I ran across some possibly rare cases that didn't seem to be handled by your tool. I added test cases for them as well.

Thanks for making this tool available. It really helped me to do some quick profiling.