script api cleanup; better segments