Minor optimizations for ocr