pull in improvements from #308