Refactors cursor change listener to be more readable
Fixes existing structure as input to support all types
Cleans up and restructures code.