Rewrote cursor mixing and simplified code.