Made optimizations to the diff bounds calculation