cpp: final fixes and hacks around visitor to get tests to pass