Fix off-by-one error in selection string.
Allow clipboard contents to be retrieved more than once.
Define and use a sgn() function