Fix for #24 in branch ocr-execute-api. Not thoroughly tested though...