misc overflow fixes, for corner cases