merged missing commits from 304..311, continuing at 345