Redesigned the attributes code.
Further work on copy_function