Bugfix: SegFault resolved by using auto_ptr