Fixed some corner cases.  Can this be optimized a little more so it only tries one code path?