Corrected out-of-bounds checking in windowToMap.