pbcopy added and some refactoring