Fixed bug 1098154 + a few other corner cases....