improve speed with clFlush instead of clFinish and fix bugs