Pull fixes from 'master' into pty_test