Merge "Correct boundary check and add log."