more thorough deletion of peer_resource when error message is received. also made del a statement