Code cleanup to improve pipeline phase. Part of work towards #157.