Refactoring of renderer.

Refactoring renderer.

cleanup.

refactoring.

Swap last two characters before cursor.

refactoring.