cleanup and fix some 4.7 compile errors