Refactor to eliminate break statements, which don't seem allowed in OpenCL.