Added special handling for bad_alloc as mandated by the proposal