Fix numeric underflow on calculating window size adjustment