fixed string manipulation in remove_service(); added memory checks