refactor CAS mismatch errors; relocate mysql wrapper module