bugfixes for corner cases