fix bugs on replace, cursor and clone