Moved some code to LibClip