Added more checks for overflows.