improve stderr handling