GCP-5757 (partial) + code cleanup