Fixed wrong return value and missing member copy.

Fixes issue 2965.