porting changes from 'master'