Fix for error in delete function, improved query for community.