merging cm upstream fixes, and enhancments