Clean up cursor drawing code.