Add debug messages and fix copy command and flags.