Improve clipboard code