Merge "General code cleanup inside treewriter-related files." into experimental