removed calls to bad() in favor of fail()
replace unique_ptr for auto_ptr