misc cleanups and cherry pick commits 132, and 141