Fix two off-by-one errors and a logic error with detecting Win.